Skip to content Skip to sidebar Skip to footer

Custom AutoComplete In Android

I want to display List of Contact Names with the respective phone numbers like Vikas Patidar <9999999999> Rahul Patidar <9999999999> using AutoCompleteTe

Solution 1:

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.


Post a Comment for "Custom AutoComplete In Android"