【发布时间】:2016-05-07 05:18:28
【问题描述】:
我正在尝试在我的 ListView 中的每个项目旁边添加一个图像,但到目前为止没有任何成功。 有一个数据库,我从中检索文本数据,如下所示:
Cursor categoriesCursor = myCategoryData.getCategoriesData();
String[] displayCategories = new String[]{ CategoryDataSource.NAME};
int[] displayViews = new int[]{R.id.list_name};
setListAdapter(new SimpleCursorAdapter(
this,
R.layout.list_category,
categoriesCursor,
displayCategories,
displayViews,1));
myListView = getListView();
然后我创建一个数组来存储图像 ID
Integer[] imageIds = new Integer[]{
R.drawable.cat1,
R.drawable.cat2,
R.drawable.cat3,
};
我不知道如何将它们绑定在一起。非常感谢您的帮助!
【问题讨论】:
-
创建自定义适配器,检查this
标签: android image listview text