"无法找到android.v4.widget.SlidingPaneLayout类"例外

时间:2015-03-30 21:32:22

标签: android android-layout

我正在开发一个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文件,将该文件添加到&#34; order and export&#34;在构建路径中选项卡,重新启动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)

1 个答案:

答案 0 :(得分:0)

当然你不能。 SlidingPaneLayout的全名应为android.support.v4.widget.SlidingPaneLayout,但不应为android.v4.widget.SlidingPaneLayout

相关问题