"ArrayAdapter requires the resource ID to be a TextView" AndroidX 错误

"ArrayAdapter requires the resource ID to be a TextView" error for AndroidX

我在使用 ListView 时遇到一个问题。 我在 Whosebug 和其他网站上搜索,但没有再次修复。

Genel.java:

public class Genel extends AppCompatActivity {
MediaController mediaController;
VideoView videoview;
ListView listView;
ArrayList<String> videoList;
ArrayAdapter adapter;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_genel);

    final VideoView videoview = findViewById(R.id.Videogenel);
    listView = (ListView) findViewById(R.id.lgvideo);
    videoList= new ArrayList<>();
    videoList.add("Genel Bilgiler");


    ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.activity_list_item,videoList);
    listView.setAdapter(adapter);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position){
                case 0:
                    videoview.setVideoPath("/storage/A6D3-E544/videos/genel1.mp4");
                    break;
            }
            final MediaController mediacontroller = new MediaController(Genel.this);
            mediacontroller.setAnchorView(videoview);

            videoview.setMediaController(mediacontroller);
            videoview.requestFocus();
            videoview.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public void onPrepared(MediaPlayer mp) {
                    mp.setOnVideoSizeChangedListener(new MediaPlayer.OnVideoSizeChangedListener() {
                        @Override
                        public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
                            videoview.setMediaController(mediacontroller);
                            mediacontroller.setAnchorView(videoview);
                        }
                    });
                }
            });

            videoview.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public boolean onError(MediaPlayer mp, int what, int extra) {
                    Log.d("API123", "What " + what + " extra " + extra);
                    return false;
                }
            });

            videoview.setMediaController(mediaController);
            videoview.start();


        }
    });

XML 文件:

 <VideoView
    android:id="@+id/Videogenel"
    android:layout_width="wrap_content"
    android:layout_height="300dp"
    android:layout_gravity="center"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="0dp"
    tools:layout_editor_absoluteY="76dp" />

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/lgvideo"
    android:layout_below="@+id/Videogenel"
    android:layout_centerHorizontal="true">

</ListView>

activity_main.xml:

<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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">

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

  </RelativeLayout>

当我使用 android.R.layout.simple_list_item_1 时一切正常,使用自己的 xml 文件我得到 "java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView"。 我需要建议。

使用:ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,R.layout.support_simple_spinner_dropdown_item,videoList);

而不是:ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.activity_list_item,videoList);

删除 android.R.layout.activity_list_item 中的 android,并使用 support_simple_spinner_dropdown_item 代替 activity_list_item