tags:

views:

51

answers:

1

Hi all,

I want to display List of Contact Names with the respective phone numbers

like


Vikas Patidar <9999999999>


Rahul Patidar <9999999999>


using AutoCompleteTextView when a user type text in the mobile number field.

In default style i can only display the list of names.

Can anyone please tell me how can I implement this so that when a user select any item in list and i can display number of that in Mobile number field.

Thanks All

+2  A: 

You need use adapter for this task. For example, with SimpleAdapter:

SimpleAdapter adapter = new SimpleAdapter(context, list, R.id.row_layout, new String[] { "Name", "Phone" }, new int[] { R.id.name, R.id.phone });
autoCompleteField.setAdapter(adapter);

For this you need make a layout XML file and list must be of type List<? extends Map<String, ?>. Strings in 4th parameter are keys for maps in list. Ints in 5th parameter are identifiers of components in layout file.

Or you can extend any adapter and use it. See this link for reference.

Sergey Glotov
Hi Sergey,Thank you for your response,I am very very new to android and Java,and still i am not getting completelyPlease could you explain using a simple code snippet,
Creative-MITian