1
这是我用于Listview的代码,我在某些网站上获得了参考。它显示了一个完整的图像列表。我必须在我的数据库中放置哪些区域来设置toptext和底部文本的文本?数据库没有在ListView中显示,只有图片
public class List_View extends ListActivity {
private DBAdapter db;
private TextView toptext; private TextView bottomtext; 私人ListView lv;
公共无效的onCreate(捆绑savedInstanceState) { 尝试{
super.onCreate(savedInstanceState);
setContentView(R.layout.list);
db = new DBAdapter(this);
toptext = (TextView) findViewById (R.id.toptext);
bottomtext = (TextView) findViewById (R.id.bottomtext);
ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String, String> item;
for (int i = 0; i < 31; i++) {
item = new HashMap<String, String>();
item.put("Date:", "Saved Date");
item.put("Title:", "Saved Title");
list.add(item);
}
SimpleAdapter notes = new SimpleAdapter(this, list, R.layout.view_list,
new String[] { "date", "title" },
new int[] {R.id.toptext, R.id.bottomtext });
setListAdapter(notes);
}赶上(Throwable的E){
Log.e("DBAdapter",e.toString());
} }
,这是数据库的一部分。
public Cursor getAllEntry()
{
return db.query(DATABASE_TABLE_2, new String[] {
KEY_ROWID2,
KEY_TITLE,
KEY_ENTRY,
KEY_MOOD,
KEY_DATE,
KEY_TIME},
null,
null,
null,
null,
null,
null);
}
你的问题是不清楚的...它会帮助,如果你更好地解释它... – JaVadid 2010-06-25 06:05:58
噢好吧。我从一些特定的网站跟踪了这个例子。我想要的列表视图左侧有一个图像,右侧是2个textview。我已经将它们存储在我的数据库中了。现在我无法展示出来。只有图像出来了。 textview没有出... 所以。我将把我的数据库部分放入。 – UserA 2010-06-25 06:25:36