I found a solution for this, thanks google and search for two days. As @ torque203 suggested, I implemented my own custom adapter. First, define a new XML file for the user element in the adapter:
autocomplete_item.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Medium Text" android:paddingLeft="8dp" android:paddingRight="8dp" android:paddingTop="16dp" android:paddingBottom="16dp" android:id="@+id/lbl_name" /> </RelativeLayout>
Create a new class for your names:
Names
public class Names { public String name; }
NamesAdapter
public class NamesAdapter extends ArrayAdapter<Names> { Context context; int resource, textViewResourceId; List<Names> items, tempItems, suggestions; public NamesAdapter(Context context, int resource, int textViewResourceId, List<Names> items) { super(context, resource, textViewResourceId, items); this.context = context; this.resource = resource; this.textViewResourceId = textViewResourceId; this.items = items; tempItems = new ArrayList<Names>(items);
SearchActivity (or your main action)
.... List<Names> namesList =
source share