Lecture des contacts - Le retour
Bonjour
J'ai bien accès aux contacts du téléphone mais impossible de récupérer le nom et le numéro de téléphone.
Je nage complètement :(
Voici mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
final String[] telephone = new String[] {Phones.NAME,Phones.NUMBER};
final Cursor c = getContentResolver().query(Phones.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
final ListView listContact = (ListView)dialogContact.findViewById(R.id.ListView01);
ListAdapter adapterContact = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_2, c,
telephone,
new int[] { android.R.id.text1, android.R.id.text2 });
listContact.setAdapter(adapterContact);
listContact.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View arg1, int position, long arg3) {
String strName = c.getString(position);
String strPhone = c.getString(position + 1);
Toast toast = Toast.makeText(getApplicationContext(),strName + ',' + strPhone, Toast.LENGTH_LONG);
toast.show();
dialogContact.dismiss();
}
}); |
Merci pour le coup de main
EDIT : La suite et la résolution sont ici : http://www.developpez.net/forums/d96...ntacts-retour/