繁体   English   中英

“找不到android.v4.widget.SlidingPaneLayout类”异常

[英]“android.v4.widget.SlidingPaneLayout class could not be found” exception

我正在开发一个android应用程序,我想使用SlidingPaneLayout。 我的activity_main.xml是:

<?xml version="1.0" encoding="utf-8"?>

<android.v4.widget.SlidingPaneLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" tools:context="absolute.beginners.hellouniverse.MainActivity" 
    android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/spLayout" >

    <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content">    
        <TextView android:text="@string/name" />        
    </LinearLayout>

</android.v4.widget.SlidingPaneLayout>

此xml在xml编辑器中未给出任何错误。 当我尝试查看图形布局时,不断出现此错误:

Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be found:
- android.v4.widget.SlidingPaneLayout (Fix Build Path, Edit XML, Create Class)

我在AndroidManifest.xml中使用sdk是:

<uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

我正在Windows 8计算机上使用Eclipse IDE Luna Release 2(4.4.2),并且android-sdk和支持库是最新版本。

我搜索了stackoverflow,并找到了很多有关此类错误的答案。 我已经尝试了所有方法:在libs文件夹中添加了android-support-v4.jar文件,将该文件添加到了构建路径中的“命令和导出”选项卡中,重新启动eclipse,一次又一次清理项目,但是我没有解决方案。

谁能帮我这个例外?

更新:运行应用程序时,模拟器正在打开,程序崩溃。 错误消息是:

03-31 02:13:48.870: E/AndroidRuntime(1129): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.v4.widget.SlidingPaneLayout
03-31 02:13:48.870: E/AndroidRuntime(1129):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
03-31 02:13:48.870: E/AndroidRuntime(1129):     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)

当然不能。 SlidingPaneLayout的全名应该是android.support.v4.widget.SlidingPaneLayout而不是android.v4.widget.SlidingPaneLayout

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM