How to set an EditText on top of a ListView ?
Posted
by Spredzy
on Stack Overflow
See other posts from Stack Overflow
or by Spredzy
Published on 2010-04-06T08:45:35Z
Indexed on
2010/04/06
9:33 UTC
Read the original article
Hit count: 569
Hi everyone,
I am trying to do an autocomplete version my way (logic, layout, etc...) , so I don't want to use the AutoCompleteTextView. My question is how to set an EditText on top of a ListView in a class inheriting from a ListAcvitivy.
I tried two kinds of layout, none of them worked.
First one :
<EditText android:id="@+id/autocomplete_server"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:completionThreshold="1"
android:singleLine="true"/>
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
<TextView android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF0000"
android:text="No data"/>
This one only shows me the EditText but does not display the list Second one :
<LinearLayout android:id="@id/android:list"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<EditText android:id="@+id/autocomplete_server"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:completionThreshold="1"
android:singleLine="true"/>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:layout_weight="1"
android:drawSelectorOnTop="false"/>
</LinearLayout>
This sample gives me a : java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eip.core/com.eip.core.Search}: java.lang.ClassCastException: android.widget.LinearLayout
Does anyone have any idea bout how to implement an EditText on top of a listView ?
© Stack Overflow or respective owner