渲染问题:无法实例化类:-android.support.v4.widget.DrawerLayout [英] Rendering Problems: Class could not be instantiated: - android.support.v4.widget.DrawerLayout
问题描述
我是新手,正在尝试开发android应用. 我使用了以下教程,一切都很好(即没有错误/红色图标). http://developer.android.com/training/implementing-navigation/nav -drawer.html
I am newbie and trying to develop android app. I used following tutorial and everything is good (i.e. no error/red icon). http://developer.android.com/training/implementing-navigation/nav-drawer.html
但是,在活动xml文件中,出现以下错误: 无法实例化以下类: -android.support.v4.widget.DrawerLayout(打开类,显示异常)
However, on activity xml file I am getting following error: The following classes could not be instantiated: - android.support.v4.widget.DrawerLayout (Open Class, Show Exception)
我已经搜索过Google,并且堆栈溢出.发现了类似的问题,但是没有人回答.假设有人遇到同样的问题并设法解决.
I have searched google and stack overflow. Found similar issue, However no one answered for those. Assuming if someone faced same problem and managed to resolve.
注意:我正在使用Android-Studio.
Note: I am using Android-Studio.
Activty.xml具有以下流程:
Activty.xml have following flow:
<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中),并且可以正确呈现.
The problem is that you're probably using a lower minSdkVersion. I had the same problem, I had set the minSdkVersion to 14, change it to 17 (in the build.gradle) and it renders correctly.
这篇关于渲染问题:无法实例化类:-android.support.v4.widget.DrawerLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!