連絡先リストに 3 つの連絡先を追加しました。次に、カーソルと ListAdapter を使用してそれらを表示 (リスト) したいと考えました。エラーは発生しませんが、画面に表示される連絡先のリストの代わりに、次の URI のみが表示されます。
content://com.android.contacts/phone_lookup
どういう意味ですか?コードも表示するかもしれませんが、それが必要かどうかはわかりません。
手伝ってくれてありがとう!
ninetwozero による編集 (コードをインライン化):
protected void showContacts() {
String [] projection = new String[] { StructuredName.DISPLAY_NAME, Phone.NUMBER };
int[] to = new int[] { R.id.txtName, R.id.txtNumber };
txt.setText(ContactsContract.PhoneLookup.CONTENT_FILTER_URI.toString());
//Uri contacts = Data.CONTENT_URI;
Cursor managedCursor = getContentResolver().query(Data.CONTENT_URI, null, null, null, null);
startManagingCursor(managedCursor);
ListAdapter sca=new SimpleCursorAdapter(this,R.layout.list_entry,managedCursor,projection,to);
list.setAdapter(sca);
}