android - 呈现问题 : Class could not be instantiated: - android. support.v4.widget.DrawerLayout

标签 android android-layout

我是新手,正在尝试开发 Android 应用程序。 我使用了以下教程,一切都很好(即没有错误/红色图标)。 http://developer.android.com/training/implementing-navigation/nav-drawer.html

但是,在 Activity xml 文件中,我收到以下错误: 无法实例化以下类: - android.support.v4.widget.DrawerLayout(公开课,显示异常)

我搜索了 google 和 stack overflow。发现了类似的问题,但是没有人回答这些问题。假设有人遇到同样的问题并设法解决。

注意:我使用的是 Android-Studio。

Activty.xml 有以下流程:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout" ...........
tools:context=".MyActivity">

    <FrameLayout
        android:id="@+id/content_frame"........
        android:layout_alignParentEnd="true">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    </FrameLayout>

    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"........
        android:background="#111"/>

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

最佳答案

问题是您可能使用了较低的 minSdkVersion。我遇到了同样的问题,我将 minSdkVersion 设置为 14,将其更改为 17(在 build.gradle 中)并且它可以正确呈现。

关于android - 呈现问题 : Class could not be instantiated: - android. support.v4.widget.DrawerLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25830927/

相关文章:

具有文本密码输入类型的Android EditText不会通过双击选择所有字符

java - Android从其他线程获取EditText内容

java - Android滤镜,改变可绘制颜色

android - VideoView 无法播放资源中的视频

android - 实现自 api 17 以来已弃用的滑动抽屉的替代方法

android - 可扩展 ListView android中的不同 subview

android - Android 中的 DatePicker 日历 View

android - 折叠工具栏标题未居中

android - iOS 是否有类似于 Android 的 RecyclerView 的东西?

android - 将 View /布局膨胀到另一个布局?