所以,我已经实现了在我的edittext中添加联系人,但我想知道我们是否可以进行多项选择并将其添加到edittext或textview
这是我的OnActivityResult代码
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
int i;
if(requestCode == CONTACT_PICKER_RESULT){
if(resultCode == RESULT_OK){
Uri contactData = data.getData();
Cursor cursor = getContentResolver().query(contactData, null, null, null, null);
cursor.moveToFirst();
String number = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
String name = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
phNo.setText(name + " " + "(" + number + ")");
}
}
}
这是我认为可以做多选的事情
if (cursor.moveToFirst()) {
while (cursor.isAfterLast() == false) {
phoneNumber = cursor.getString(phoneIdx);
allNumbers.add(phoneNumber);
cursor.moveToNext();
}
任何帮助将不胜感激