Android 抽屉布局未显示在我的预览窗口上。如何修复此问题?

Android 抽屉布局未显示在我的预览窗口上。如何修复此问题?,android,drawerlayout,Android,Drawerlayout,我已将抽屉布局添加到我的应用程序中。但它并没有被展示出来。当我在emulator上运行应用程序时,它会自动打开然后关闭。 这是布局文件:- ?xml version="1.0" encoding="utf-8"?> <androidx.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas

我已将抽屉布局添加到我的应用程序中。但它并没有被展示出来。当我在emulator上运行应用程序时,它会自动打开然后关闭。

这是布局文件:-

?xml version="1.0" encoding="utf-8"?>
<androidx.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/content_frame"/>
    <ListView
        android:id="@+id/drawer"
        android:layout_width="240dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:text="Hello World!"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#ffffff"/>


</androidx.support.v4.widget.DrawerLayout>

您忘了在导航抽屉未工作的情况下添加导航


或者你可以从这里举个例子,它对我有效

你忘了添加导航而没有导航抽屉不起作用


或者你可以从这里举个例子,它对我有用

我必须在哪里添加导航?我给你发送链接,你可以查看它。它为meis工作,您可以通过任何方式向我发送代码的屏幕截图吗?我必须在哪里添加导航?我向您发送链接,您可以查看它。它为meis工作,你能给我发代码的截图吗?
apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.bitsandpizzas"
        minSdkVersion 17
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'

    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}