【eclipse】使用support.v4新增控件DrawerLayout抽屉布局出现的问题
记录一下在eclipse中使用DrawerLayout出现的问题:
1、ClassNotFoundException
07-27 17:13:33.710: E/AndroidRuntime(3702): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.widget.DrawerLayout" on path: DexPathList[[zip file "/data/app/com.test.testandroid-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
07-27 17:13:33.710: E/AndroidRuntime(3702): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
07-27 17:13:33.710: E/AndroidRuntime(3702): at android.view.LayoutInflater.createView(LayoutInflater.java:571)
07-27 17:13:33.710: E/AndroidRuntime(3702): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
07-27 17:13:33.710: E/AndroidRuntime(3702): ... 20 more
07-27 17:13:33.710: E/AndroidRuntime(3702): Suppressed: java.lang.ClassNotFoundException: android.support.v4.widget.DrawerLayout
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.Class.classForName(Native Method)
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
07-27 17:13:33.710: E/AndroidRuntime(3702): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
07-27 17:13:33.710: E/AndroidRuntime(3702): ... 23 more
07-27 17:13:33.710: E/AndroidRuntime(3702): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
原因:support.v4导包后,没有在Order and Export中勾选v4包,
具体说明如下:
buid Path配置里, libraries页是否有v4包, Order and Export 是否勾选V4包(可以把它移到顶层)
具体参看:http://www.oschina.net/question/944625_184112
2、使用DrawerLayout设置布局时,需要指定某布局layout_gravity,否则,无法弹出DrawerLayout侧边布局.
layout_gravity的作用:指定某布局为抽屉侧边栏布局;否则出现如下错误,
crash:
java.lang.IllegalArgumentException: No drawer view found with absolute gravity LEFT