0
中顯示聯繫人的名字,我想只要從設備電話簿中的聯繫人,並在旋轉器上,代碼顯示出來:安卓:在微調
// Form an array specifying which columns to return.
String[] PROJECTION = new String[] {
People._ID, People.NAME
};
// Get the base URI for the People table in the Contacts content provider.
Uri contacts = People.CONTENT_URI;
Spinner contactsSpinner = (Spinner) findViewById(R.id.recipient_names);
// Make the query.
Cursor contactsCursor = managedQuery(contacts,
PROJECTION, // Which columns to return
null, // Which rows to return (all rows)
null, // Selection arguments (none)
// Put the results in ascending order by name
People.NAME + " ASC");
Log.e("EE", String.valueOf(contactsCursor.getCount()));
SimpleCursorAdapter sca = new SimpleCursorAdapter(
this, android.R.layout.simple_spinner_item,
contactsCursor, new String[] {People.NAME}, new int[] {android.R.id.text1}
);
Log.e("EE", String.valueOf(sca.getCount()));
sca.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
contactsSpinner.setAdapter(sca);
編譯和運行正常,只是.. Log.e()調用顯示爲1,我認爲這意味着聯繫人實際上已成功檢索到,但是Spinner是空的......任何人都可以告訴我我做錯了嗎?