AutoCompleteTextView
我在android中扩展。当我在我的 XML 布局文件中使用该新自定义AutoCompleteTextView
时,Eclipse 显示一条错误消息:
在尝试显示弹出窗口之前,您必须通过调用 setContentView() 来指定有效的内容视图。异常详细信息记录在“窗口”>“显示视图”>“错误日志”中。
编辑的 XML 文件是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.mypackage.MyAutoCompleteTextView
android:id="@+id/countries_list_custom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:completionHint="Test">
<requestFocus />
</com.mypackage.MyAutoCompleteTextView>
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
通过简单地从 XML 中取出我的自定义视图,布局显示得很好。
任何帮助将不胜感激,谢谢。