Android AutoCompleteTextView作为ListView标题

Android AutoCompleteTextView作为ListView标题,android,listview,autocompletetextview,Android,Listview,Autocompletetextview,我正在尝试将AutoCompleteTextView设置为ListView标题,但如果我这样做,则不会出现autocomplete框。创建自动完成视图的代码直接来自谷歌文档中的教程。国家阵列也来自那里 protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); setContentVie

我正在尝试将AutoCompleteTextView设置为ListView标题,但如果我这样做,则不会出现autocomplete框。创建自动完成视图的代码直接来自谷歌文档中的教程。国家阵列也来自那里

protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ListView myList = (ListView) findViewById(R.id.ResultList);

LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
TableLayout searchHeader = (TableLayout) layoutInflater.inflate(R.layout.search_header, null); 
myList.addHeaderView(searchHeader, null, false);

final AutoCompleteTextView textView = (AutoCompleteTextView) myList.findViewById(R.id.edit);
ArrayAdapter<String> searchAdapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_dropdown_item_1line, COUNTRIES);
textView.setAdapter(searchAdapter);
textView.setThreshold(1);

        //Dummy data for listview.

String[] listContent = {
        "test", "test", "test", "test",
        "test", "test", "test", "test"
};
ArrayAdapter<String> adapter = new SearchResultAdapter(this, listContent);
myList.setAdapter(adapter);

}
对话框出现,但几乎立即关闭。我想知道是否是列表视图中冒泡的某种事件导致了这种情况?

关于列表视图中EditText视图的焦点&阅读AutoCompleteTextView源代码帮助我找到了答案。将ListView上的焦点顺序设置为AfterDescents可使对话框正常显示

<ListView
    android:id="@+id/ResultList"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="50dip"
    android:descendantFocusability="afterDescendants"
    android:fadingEdge="none" >
</ListView>

关于ListView中EditText视图的焦点&阅读AutoCompleteTextView源代码帮助我找到了答案。将ListView上的焦点顺序设置为AfterDescents可使对话框正常显示

<ListView
    android:id="@+id/ResultList"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_marginBottom="50dip"
    android:descendantFocusability="afterDescendants"
    android:fadingEdge="none" >
</ListView>


在您的XML文件中使用autocompletetextview可能会有帮助

在您的XML文件中使用autocompletetextview可能会有帮助

您能帮我做这件事吗?您能帮我做这件事吗!言语无法表达喜悦,哈哈!