gpt4 book ai didi

android - 膨胀类 android.support.v4.view.PagerTabStrip 时出错

转载 作者:行者123 更新时间:2023-11-29 01:52:01 29 4
gpt4 key购买 nike

我正在尝试使用 android.support.v4.view.ViewPager 中的 ViewPager 项运行应用程序。这很好用,所以接下来我想使用 android.support.v4.view.PagerTabStrip 将顶部项目添加到它。当我想在模拟器上运行它时,这会引发错误。错误是:

二进制 XML 文件第 12 行:扩展类 android.support.v4.view.PagerTabStrip 时出错

我已经将模拟器的版本更改为 google api,但没有区别。我也尝试过将 user-lib 添加到 list 中,但这也不会部署它。有人有什么想法吗?

我也在 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>

最佳答案

啊哈,明白了。我所做的是删除文件的 Maven 版本并将其直接从 androidsdk 目录添加到库中。可能有一种方法可以将它包含在文件中,但我无法解决。

它还需要是 ViewPager 的子项。

很奇怪 viewpager 在没有这个设置的情况下工作。

关于android - 膨胀类 android.support.v4.view.PagerTabStrip 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17420778/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com