如何将图像添加到 android 中的列表视图?
我有一个列表视图,其中有 2 个文本视图,它们由使用简单光标适配器的数据库填充。我想在列表中的每个项目中添加一个图像以及数据库中的相应图像。我已经搜索过这个主题,但尚未找到解决方案。任何帮助将不胜感激,
String[] from = new String[]{InventoryDbAdapter.KEY_TITLE, InventoryDbAdapter.KEY_DESCRIPTION};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1,R.id.text2};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter inventory =
new SimpleCursorAdapter(this, R.layout.row, InventoryCursor, from, to);
setListAdapter(inventory
谢谢
I have a listview with 2 textviews inside of it that are filled by a database using the simple cursor adapter. I want to add an image inside each item in the list with the corresponding image from the database. I have searched around about this topic but have yet to find a solution. any help would be greatly appreciated
String[] from = new String[]{InventoryDbAdapter.KEY_TITLE, InventoryDbAdapter.KEY_DESCRIPTION};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1,R.id.text2};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter inventory =
new SimpleCursorAdapter(this, R.layout.row, InventoryCursor, from, to);
setListAdapter(inventory
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
真的吗?因为通过 Google 快速搜索就找到了此博客条目我认为这与我在 Android 应用程序中使用的相同。
Really? Because a quick Google search turned up this blog entry which I think is the same one I used for my Android applications.