我正在尝试使用 android.support.v4.view.ViewPager 中的 ViewPager 项目运行应用程序。这很好用,所以接下来我想使用 android.support.v4.view.PagerTabStrip 将最重要的项目添加到它。当我想在模拟器上运行它时,这会引发错误。错误是:
二进制 XML 文件第 12 行:膨胀类 android.support.v4.view.PagerTabStrip 时出错
我已将模拟器的版本更改为 google api,没有区别。我也尝试将 user-lib 添加到清单中,但这也不会部署它。有人有什么想法吗?
我也在 Intellij 下运行它,而不是 Eclipse。
塔
//附加信息:
Logcat 发布:
07-02 15:11:30.069: DEBUG/dalvikvm(626): GC_CONCURRENT freed 393K, 5% free 10796K/11335K, paused 18ms+24ms, total 95ms
07-02 15:11:30.129: ERROR/AndroidRuntime(626): FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.matjohnson/com.matjohnson.PageViewActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.v4.view.PagerTabStrip
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class android.support.v4.view.PagerTabStrip
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
at android.app.Activity.setContentView(Activity.java:1867)
at com.matjohnson.PageViewActivity.onCreate(PageViewActivity.java:32)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
... 11 more
Caused by: java.lang.ClassNotFoundException: android.support.v4.view.PagerTabStrip
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.view.LayoutInflater.createView(LayoutInflater.java:552)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
... 22 more
07-02 15:11:30.209: WARN/ActivityManager(148): Force finishing activity com.matjohnson/.PageViewActivity
07-02 15:11:30.220: WARN/WindowManager(148): Failure taking screenshot for (328x583) to layer 21005
07-02 15:11:30.730: WARN/ActivityManager(148): Activity pause timeout for ActivityRecord{4163db60 com.matjohnson/.PageViewActivity}
07-02 15:11:41.420: WARN/ActivityManager(148): Activity destroy timeout for ActivityRecord{4163db60 com.matjohnson/.PageViewActivity}
//编辑 - 添加 XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v4.view.PagerTabStrip
android:id="@+id/pager_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#000"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff"/>
</android.support.v4.view.ViewPager>
</RelativeLayout>