Android ApiDemos示例解析(170):Views->Lists->3. Cursor (Phones)
本例和上例类似,不同的是是使用android.R.layout.易做图_list_item_2 Layout 显示列表项,
android.R.layout.易做图_list_item_2.xml 中含有两个TextView,其id 分别为 android.R.id.text1, android.R.id.text2.
对于本例,两个TextView可以分别来显示联系人的姓名和电话:
[java
Cursor c = getContentResolver().query(Phones.CONTENT_URI,
null, null, null, null);
startManagingCursor(c);
// Map Cursor columns to views defined in 易做图_list_item_2.xml
ListAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.易做图_list_item_2, c,
new String[] { Phones.NAME, Phones.NUMBER },
new int[] { android.R.id.text1, android.R.id.text2 });
setListAdapter(adapter);
Cursor c = getContentResolver().query(Phones.CONTENT_URI,
null, null, null, null);
startManagingCursor(c);
// Map Cursor columns to views defined in 易做图_list_item_2.xml
ListAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.易做图_list_item_2, c,
new String[] { Phones.NAME, Phones.NUMBER },
new int[] { android.R.id.text1, android.R.id.text2 });
setListAdapter(adapter);
补充:移动开发 , Android ,