我想通过滚动功能向用户显示我的数据库的一些内容。
所以我扩展了 ListActivity 并使用了 SimpleCursorAdapter。问题是我看不到被取代的价值观。
private void fillData() {
// Get all of the rows from the database and create the item list
ListData = data.findAllDbValues();
startManagingCursor(ListData);
// Create an array to specify the fields we want to display in the list
String[] from = new String[]{Data.ID, Data.DESC};
// and an array of the fields we want to bind those fields to
int[] to = new int[]{R.id.text1, R.id.text2};
// Now create a simple cursor adapter and set it to display
ListAdapter la = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, ListData, from, to);//R.layout.showdata
setListAdapter(la);
}
如果我使用自定义布局(R.layout.showdata),它只有两个 TextView,我可以看到这些值,但我必须触摸显示的文本才能完成我的工作,而不是仅仅触摸选择的任何地方。
所以我想使用一个 simple_list_item_2 这样我就可以拥有这个能力。有什么想法为什么我看不到这些值,或者我怎样才能使我的自定义布局产生与 simple_list 相同的能力?