MaterialAutoCompleteTextView dropdownmenu/adapter 未显示

MaterialAutoCompleteTextView dropdownmenu/adapter not shown

我有一个简单的设置:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="#C9E44B"
 tools:context=".pkgTestforend.DriverAddOptionalDataFragment">

    <com.google.android.material.textfield.TextInputLayout
        style="Theme.MaterialComponents.Light.Bridge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="visible"
        >

        <com.google.android.material.textfield.MaterialAutoCompleteTextView
            android:id="@+id/filled_exposed_dropdown"
            android:layout_width="200dp"
            android:visibility="visible"
            android:layout_height="wrap_content" />

    </com.google.android.material.textfield.TextInputLayout>

</RelativeLayout>

我正在尝试使用简单的适配器使下拉菜单可见:

MaterialAutoCompleteTextView filled_exposed_dropdown;
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    String [] randomArray = new String[3];
    randomArray[0] = " test ";
    randomArray[1] = " values";
    randomArray[2] = " ofcourse";

    ArrayList<String> items = new ArrayList<String>(Arrays.asList(randomArray));
    ArrayAdapter<String> h = new ArrayAdapter(getContext(),R.layout.list_item, items);

    filled_exposed_dropdown = view.findViewById(R.id.filled_exposed_dropdown);
    filled_exposed_dropdown.setAdapter(h);
}

最后但同样重要的是我的 list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="16dp"
    android:ellipsize="end"
    android:maxLines="1"
    android:textAppearance="?attr/textAppearanceSubtitle1"
    />
</menu>

但是,尝试在启动我的应用程序时使下拉菜单可见如下所示:

问题是我只能写一个新项目,但下拉菜单不可见。我错过了什么?大部分代码基于原始 material.io 文档。

filled_exposed_dropdown.showDropDown() 

丢失。 ;)