gpt4 book ai didi

android - ViewPagerIndicator ClassNotFoundException?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:55:42 27 4
gpt4 key购买 nike

我正在尝试在我的项目中使用 Jake Wharton 的 ViewPagerIndicator 库,我遵循了此处列出的简单教程:

http://viewpagerindicator.com/

但是当我尝试运行我的项目时,我不断收到 ClassNotFoundException

这是我的布局中的 XML:

<android.support.v4.view.ViewPager
android:id="@+id/day_pager"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />

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

这是我的相应代码(dayPageViewPager 类型)。

    ArrayList<Integer> testData = new ArrayList<Integer>();
testData.add(12);
testData.add(13);
testData.add(22);

dayPage = (ViewPager) this.getActivity().findViewById(R.id.day_pager);
dayPage.setAdapter(new DayAdapter(testData));

//Bind the title indicator to the adapter
TitlePageIndicator titleIndicator = (TitlePageIndicator)this.getActivity().findViewById(R.id.titles);
titleIndicator.setViewPager(dayPage);

testData 中的值目前是垃圾。

完整的堆栈跟踪是:

08-25 22:32:23.420: E/AndroidRuntime(1710): FATAL EXCEPTION: main
08-25 22:32:23.420: E/AndroidRuntime(1710): android.view.InflateException: Binary XML file line #12: Error inflating class com.viewpagerindicator.TitlePageIndicator
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-25 22:32:23.420: E/AndroidRuntime(1710): at vt.finder.sherlock.ScheduleFragment.onCreateView(ScheduleFragment.java:50)
08-25 22:32:23.420: E/AndroidRuntime(1710): at vt.finder.sherlock.ScheduleFragment.onCreate(ScheduleFragment.java:30)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:835)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.view.ViewPager.populate(ViewPager.java:895)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1234)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.View.measure(View.java:8313)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.View.measure(View.java:8313)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.View.measure(View.java:8313)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.View.measure(View.java:8313)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.View.measure(View.java:8313)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.os.Looper.loop(Looper.java:130)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-25 22:32:23.420: E/AndroidRuntime(1710): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 22:32:23.420: E/AndroidRuntime(1710): at java.lang.reflect.Method.invoke(Method.java:507)
08-25 22:32:23.420: E/AndroidRuntime(1710): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-25 22:32:23.420: E/AndroidRuntime(1710): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-25 22:32:23.420: E/AndroidRuntime(1710): at dalvik.system.NativeStart.main(Native Method)
08-25 22:32:23.420: E/AndroidRuntime(1710): Caused by: java.lang.ClassNotFoundException: com.viewpagerindicator.TitlePageIndicator in loader dalvik.system.PathClassLoader[/data/app/vt.finder.sherlock-1.apk]
08-25 22:32:23.420: E/AndroidRuntime(1710): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-25 22:32:23.420: E/AndroidRuntime(1710): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-25 22:32:23.420: E/AndroidRuntime(1710): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
08-25 22:32:23.420: E/AndroidRuntime(1710): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
08-25 22:32:23.420: E/AndroidRuntime(1710): ... 37 more

我将 ViewPagerIndicator 项目作为库导入到我的项目中,我再次检查包名称是否完整,确实如此。我对我的项目做了一个清理,但我仍然得到类未找到异常。我错过了什么吗?

最佳答案

很多人把它添加到lib的文件夹或导入它(这是不正确的)

相反,您需要在库部分的属性/android 对话框下添加整个项目(源和所有资源)(如下所示)

如果您不确定自己做了什么,请尝试删除对库的所有引用,使其不在库或引用的库文件夹中,并且不会显示在属性/java 构建路径 - 库选项卡下

然后通过 properties/android 对话框将整个项目添加回,进行干净的构建(有时两次,感谢 eclipse),它应该可以正常工作。

added it to Eclipse

关于android - ViewPagerIndicator ClassNotFoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12126194/

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