The main layout have four widgets- one EditText and three TextView as given below.
I want to add suggestion-list view dynamically as given below:
How to do it?
The main layout have four widgets- one EditText and three TextView as given below.
I want to add suggestion-list view dynamically as given below:
How to do it?
You can use AutoCompleteTextView. Described in http://developer.android.com/guide/topics/ui/controls/text.html.
Probably Custom adapter will help you to make two suggestions lists. Take a look at this Autocompletetextview with custom adapter and filter. I guess you need to create divider in custom adapter.
As described in comments. Just Make listview visible when you need to show suggestions. Or paste in eclipse and remove android:visibility="gone" attribute and you will see gray listview over textviews.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/search"
android:text="text1" />
<TextView
android:id="@+id/tv_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_1"
android:text="text2" />
<ListView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_below="@id/search"
android:background="@android:color/darker_gray"
android:visibility="gone" />
</RelativeLayout>
There is a class already built into android which gives you think functionality.
It's called AutoCompleteTextView