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