我想要做一个自动完成版本我的方式(逻辑,布局, 等...),所以我不想使用AutoCompleteTextView。 我的问题是如何在继承自ListAcvitivy的类 的ListView顶部设置EditText。如何在ListView上设置EditText?
我尝试了两种布局,他们都没有工作。
第一招:
<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"/>
这一次只显示我的EditText,但不显示列表 第二个:
<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>
此示例给了我: 了java.lang.RuntimeException :无法启动活动 ComponentInfo {com.eip.core/com.eip.core.Search}: java.lang.ClassCastException:android.widget.LinearLayout
有没有人有任何想法回合如何实现一个EditText的顶部 listView?
非常感谢它的工作! – Spredzy 2010-04-07 08:31:13