Android 导航抽屉中的自动完成文本视图不显示结果

Android 导航抽屉中的自动完成文本视图不显示结果,android,xml,arraylist,autocomplete,Android,Xml,Arraylist,Autocomplete,我试图使用导航抽屉菜单顶部的自动完成文本视图从数组列表显示。我可以打字,但没有显示任何结果。请帮忙,我想是因为风景。这里是主要活动 Detalles.java NavigationView navigationView = null; Toolbar toolbar = null; AutoCompleteTextView autoTextView; String[] ciudades; @Override protected void onCreat

我试图使用
导航抽屉
菜单顶部的
自动完成文本视图
数组列表
显示。我可以打字,但没有显示任何结果。请帮忙,我想是因为风景。这里是主要活动

Detalles.java

 NavigationView navigationView = null;
    Toolbar toolbar = null;
    AutoCompleteTextView autoTextView;
    String[] ciudades;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_detalles);


        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);



        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);


        LayoutInflater inflator = (LayoutInflater) this
                .getSystemService(this.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(R.layout.nav_header_detalles, null);

        autoTextView  = (AutoCompleteTextView) v.findViewById(R.id.autoTextView);
        ciudades = getResources().getStringArray(R.array.ciudades);
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),android.R.layout.simple_dropdown_item_1line,ciudades);

        autoTextView.setAdapter(adapter);
        autoTextView.setThreshold(1);
    }

The **nav_header_detalles.xml** file which contains the AutoComplete TextView:

    <?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="wrap_content"
    android:background="@drawable/side_nav_bar"
    android:paddingBottom="6dp"
    android:paddingLeft="6dp"
    android:paddingRight="6dp"
    android:paddingTop="6dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:orientation="vertical"
    android:gravity="bottom"
    android:padding="6dp"
    android:id="@+id/autoLayout">



    <AutoCompleteTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/autoTextView"
        android:ems="10"
        android:hint="@string/autoTextViewHint" />

</LinearLayout>

The main xml: activity_detalles.xml:

       <?xml version="1.0" encoding="utf-8"?>
      <android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start"
    android:theme="@style/AppTheme">


    <include
        layout="@layout/app_bar_detalles"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_detalles"
        app:menu="@menu/activity_detalles_drawer" />

    </android.support.v4.widget.DrawerLayout>
NavigationView-NavigationView=null;
工具栏=空;
自动完成图文视图自动图文视图;
字符串[]ciudades;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detalles);
toolbar=(toolbar)findviewbyd(R.id.toolbar);
设置支持操作栏(工具栏);
抽屉布局抽屉=(抽屉布局)findViewById(R.id.抽屉布局);
ActionBarDrawerToggle切换=新建ActionBarDrawerToggle(
这,抽屉,工具栏,R.string.navigation\u drawer\u open,R.string.navigation\u drawer\u close);
抽屉。设置抽屉定位器(开关);
toggle.syncState();
navigationView=(navigationView)findViewById(R.id.nav_视图);
navigationView.setNavigationItemSelectedListener(此);
LayoutInflater充气机=(LayoutInflater)此
.getSystemService(此.LAYOUT\u充气机\u服务);
视图v=充气机。充气(右布局。导航标题,空);
autoTextView=(AutoCompleteTextView)v.findViewById(R.id.autoTextView);
ciudades=getResources().getStringArray(R.array.ciudades);
ArrayAdapter=新的ArrayAdapter(getApplicationContext(),android.R.layout.simple\u下拉菜单\u item\u 1line,ciudades);
autoTextView.setAdapter(适配器);
autoTextView.setThreshold(1);
}
包含自动完成文本视图的**nav_header_detalles.xml**文件:

好的,我自己找到了答案,尽管这与我在乞讨中想要的有点不同。 解决办法是:

1) 删除$DroperLayout的$NavigationView中的app:header声明

2) 在$MainActivity:Detalles中包括以下内容: navigationView=(navigationView)findViewById(R.id.nav_视图); navigationView.setNavigationItemSelectedListener(此)

LayoutInflater充气机=(LayoutInflater)此
.getSystemService(此.LAYOUT\u充气机\u服务);
视图v=充气机。充气(右布局。导航标题,空);
navigationView.addHeaderView(v);
autoTextView=(AutoCompleteTextView)v.findViewById(R.id.autoTextView);
ciudades=getResources().getStringArray(R.array.ciudades);
ArrayAdapter=新的ArrayAdapter(navigationView.getContext(),android.R.layout.simple\u dropdown\u item\u 1line,ciudades);
autoTextView.setAdapter(适配器);
autoTextView.setThreshold(1);
<string-array name="ciudades">
    <item>Albacete</item>
    <item>Alcala de Henares</item>
    <item>Alcobendas</item>
    <item>Alcorcon</item>
    <item>Algeciras</item>
    <item>Alicante</item>
    <item>Almeria</item>
    <item>Almoradi</item>
    <item>Altea</item>
    <item>Badalona</item>
</string-array>
    LayoutInflater inflator = (LayoutInflater) this
            .getSystemService(this.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.nav_header_detalles, null);
    navigationView.addHeaderView(v);

    autoTextView  = (AutoCompleteTextView) v.findViewById(R.id.autoTextView);
    ciudades = getResources().getStringArray(R.array.ciudades);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(navigationView.getContext(),android.R.layout.simple_dropdown_item_1line,ciudades);
    autoTextView.setAdapter(adapter);
    autoTextView.setThreshold(1);