0
我已經使用此代碼,但結果不是我在listview中選擇的名稱的信息,而是來自其他名稱的信息。如何從列表視圖中獲取聯繫人詳細信息android
contactmanager.java
protected void onListItemClick(ListView l, View v, int position, long id)
{
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, ContactEditor.class);
i.putExtra(ContactsContract.Contacts._ID, id);
startActivityForResult(i, 2);
}
ContactEditor.java
private Long mRowId;
mRowId = savedInstanceState != null ? savedInstanceState.getLong(ContactsContract.Contacts._ID):null;
if (mRowId == null){
Bundle extras = getIntent().getExtras();
mRowId = extras != null ? extras.getLong(ContactsContract.Contacts._ID):null;
}
populateFields();
private void populateFields(){
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
if (mRowId != null)
{
while (cur.moveToNext()) {
String id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
mContactNameEditText.setText(name);
}
}
}
SAAAAAAM ..你的答案是me..4天,我被卡在這種情況下非常滿意。非常感謝你的兄弟。 – Fuji