gpt4 book ai didi

android - 来自多个内容提供商的结果的光标 - Android

转载 作者:太空宇宙 更新时间:2023-11-03 13:35:45 24 4
gpt4 key购买 nike

我想查询两个不同的内容提供者:

MediaStore.Images.Media.EXTERNAL_CONTENT_URI

MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI

首先,我需要查询“MediaStore.Images.Media.EXTERNAL_CONTENT_URI”,以便我可以获得在特定日期之后添加的所有图像的光标。我现在知道该怎么做了。问题出在缩略图上。我还需要查询“MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI”以获取缩略图图像,以便我可以在 ListView 中显示它们。这是我不知何故需要组合两个查询的结果,因为我只想要在特定日期之后添加的图像的缩略图。但是“MediaStore.Images.Thumbnails”没有关于图像添加时间的信息。它只有“MediaStore.Images.Media”中原始图像的 ID。

所以,总结一下我需要帮助的方面:

我需要一个包含以下列的游标:

MediaStore.Images.Thumbnails.IMAGE_ID,

MediaStore.Images.Thumbnails._ID,

MediaStore.Images.Thumbnails.DATA,

MediaStore.Images.Media.DATA,

MediaStore.Images.Media.DATE_TAKEN

如何做到这一点?

感谢您的帮助!

最佳答案

您可以从一个提供程序中选择数据,然后使用 ViewBinder 按行选择。

Within MyActivity.onCreate() {
...
cursorAdapter.setViewBinder(myViewBinder),
...
}

在某个地方你像这样实现你的 ViewBinder...

private final ViewBinder myViewBinder=new ViewBinder() {
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if(columnIndex==INDEX_OF_THUMB) {
int id=cursor.get("_id");
// get thumb-image data for id from somewhere
// and display in view
}
};

希望这对您有所帮助。

关于android - 来自多个内容提供商的结果的光标 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7554057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com