动态添加图像到ListView
我知道这个问题听起来很熟悉,你会告诉我,如果进行一些搜索,我应该找到答案......但请没有任何对我有用!
我需要一个可以动态添加特定图像到每行内容的代码!
super.onCreate(savedInstanceState);
DatabaseHelper helper = new DatabaseHelper(this);
database = helper.getWritableDatabase();
Cursor data = database.query("names", fields, null, null, null, null,
null);
dataSource = new SimpleCursorAdapter(this, R.layout.row, data, fields,
new int[] { R.id.first, R.id.last });
ListView view = getListView();
view.setHeaderDividersEnabled(true);
view.addHeaderView(getLayoutInflater().inflate(R.layout.row, null));
setListAdapter(dataSource);
}
I know this question sound familiar and you will tell me that I should find my answer if made a little search on it... but pls nothing is working for me!
I need a code that can add dynamically a specific image to each row content!
super.onCreate(savedInstanceState);
DatabaseHelper helper = new DatabaseHelper(this);
database = helper.getWritableDatabase();
Cursor data = database.query("names", fields, null, null, null, null,
null);
dataSource = new SimpleCursorAdapter(this, R.layout.row, data, fields,
new int[] { R.id.first, R.id.last });
ListView view = getListView();
view.setHeaderDividersEnabled(true);
view.addHeaderView(getLayoutInflater().inflate(R.layout.row, null));
setListAdapter(dataSource);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里只是一个疯狂的猜测 - 因为这个问题真的很难理解。
您有一个对象列表,其中包含
我建议使用自定义列表视图适配器来填充水平线性布局,其中包含一个 ImageView 和两个文本视图。
这个演示确实帮助我开始使用 ListViews,我建议观看它。
http://www.google.com/events /io/2010/sessions/world-of-listview-android.html
Just a wild guess here - because the question is really hard to understand.
You have a List of Objects that have
I would suggest using a custom listview adapter to fill a horizontal linear layout which holds an ImageView and two text views.
This presentation really helped me to get started with ListViews, and I would recommend watching it.
http://www.google.com/events/io/2010/sessions/world-of-listview-android.html