gpt4 book ai didi

java - ViewPager 下方的 TitlePageIndicator

转载 作者:行者123 更新时间:2023-12-02 07:50:16 25 4
gpt4 key购买 nike

我搜索了很多,但找不到这个问题的答案:有什么方法可以在 ViewPager 下面使用 TitlePageIndicator 吗?

我在 .xml 中尝试了相反的顺序,但得到了:

04-24 19:30:30.288: E/AndroidRuntime(3338): FATAL EXCEPTION: main
04-24 19:30:30.288: E/AndroidRuntime(3338): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.totvs.android/br.com.totvs.android.ecm.activity.TelaPrincipalActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.os.Handler.dispatchMessage(Handler.java:99)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.os.Looper.loop(Looper.java:130)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-24 19:30:30.288: E/AndroidRuntime(3338): at java.lang.reflect.Method.invokeNative(Native Method)
04-24 19:30:30.288: E/AndroidRuntime(3338): at java.lang.reflect.Method.invoke(Method.java:507)
04-24 19:30:30.288: E/AndroidRuntime(3338): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-24 19:30:30.288: E/AndroidRuntime(3338): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-24 19:30:30.288: E/AndroidRuntime(3338): at dalvik.system.NativeStart.main(Native Method)
04-24 19:30:30.288: E/AndroidRuntime(3338): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-24 19:30:30.288: E/AndroidRuntime(3338): at br.com.totvs.android.ecm.activity.TelaPrincipalActivity.onCreate(TelaPrincipalActivity.java:56)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
04-24 19:30:30.288: E/AndroidRuntime(3338): ... 11 more
04-24 19:30:30.288: E/AndroidRuntime(3338): Caused by: java.lang.ClassCastException: com.viewpagerindicator.TitlePageIndicator
04-24 19:30:30.288: E/AndroidRuntime(3338): at br.com.totvs.android.ecm.fragment.TabFragment.onCreateView(TabFragment.java:36)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:845)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1058)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1156)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:270)
04-24 19:30:30.288: E/AndroidRuntime(3338): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-24 19:30:30.288: E/AndroidRuntime(3338): ... 18 more

提前致谢,

最佳答案

这可能取决于您使用的 TitlePageIndicator 类型。但我听说过的所有版本(可能包括 Jake Wharton 最受欢迎的版本)都只是 View ,您可以将其放在任何您想要的地方。

所以你可以膨胀这样的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
</android.support.v4.view.ViewPager>

<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/titles"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />



</LinearLayout>

还有来自 Commonsware 的极其重要的说明。项目->清理

关于java - ViewPager 下方的 TitlePageIndicator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10304600/

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