1

I show phone contacts in a listview with these codes :

LayoutInflater inflater = getLayoutInflater();
View dialoglayout = inflater.inflate(R.layout.contact_list, null);
AlertDialog.Builder builder = new AlertDialog.Builder(Etelaat.this);
builder.setView(dialoglayout);
listContacts = (ListView) dialoglayout.findViewById(R.id.conactlist);
Uri queryUri = ContactsContract.Contacts.CONTENT_URI;
String[] projection = new String[] {
ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME};

String selection = ContactsContract.Contacts.DISPLAY_NAME + " IS NOT NULL";
CursorLoader cursorLoader = new CursorLoader(Etelaat.this, queryUri, projection, selection, null, null);
Cursor cursor = cursorLoader.loadInBackground();
String[] from = {ContactsContract.Contacts.DISPLAY_NAME};
int[] to = {android.R.id.text1};

ListAdapter adapter = new SimpleCursorAdapter(Etelaat.this,android.R.layout.simple_list_item_1, cursor,from, to, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
listContacts.setAdapter(adapter);
listContacts.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        // ??????????????????
    }
});

I need to get contact phone number with click on list view item and save it to a String or int, so how should I do that?

Bruno Parmentier
  • 1,219
  • 2
  • 14
  • 34
Sajad Rahmanipour
  • 397
  • 1
  • 3
  • 20
  • have you tried this..http://stackoverflow.com/questions/9496350/pick-a-number-and-name-from-contacts-list-in-android-app – Vikas Mane May 20 '15 at 18:56

0 Answers0