simpleCursorAdapter
/* SimpleCursorAdapter的使用方法 结合cursor一起使用*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_main);
// 该listView是一个groupView 是用来容纳其他的view的
ListView contactListView = (ListView)findViewById(R.id.contactList);
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
String[] colums=new String[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME,ContactsContract.Contacts.HAS_PHONE_NUMBER};
int[] entries=new int[]{R.id._id,R.id.name,R.id.number};
// 将没一行数据填充到对应的view之中
SimpleCursorAdapter adapter=new SimpleCursorAdapter(this, R.layout.concact, cursor, colums, entries);
contactListView.setAdapter(adapter);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.activity_main);
// 该listView是一个groupView 是用来容纳其他的view的
ListView contactListView = (ListView)findViewById(R.id.contactList);
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
String[] colums=new String[]{ContactsContract.Contacts._ID,ContactsContract.Contacts.DISPLAY_NAME,ContactsContract.Contacts.HAS_PHONE_NUMBER};
int[] entries=new int[]{R.id._id,R.id.name,R.id.number};
// 将没一行数据填充到对应的view之中
SimpleCursorAdapter adapter=new SimpleCursorAdapter(this, R.layout.concact, cursor, colums, entries);
contactListView.setAdapter(adapter);
}