0

当谈到 Android 编程时,我是一个新手。现在,我正在用 android 练习基本元素。我成功地创建了链接到其他活动的按钮,并以单独的方式创建了滑动标签。

现在,问题是当我尝试合并这两个时,我在这样做时遇到了困难。

根据 Eclipse,编码中没有警告或错误,但是当我单击应该显示带有 swipeytabs 的活动的按钮时,应用程序会关闭。

这是 logCat 的内容:

06-03 17:48:57.678: I/ActionBarSherlock(907): 使用限定符注册 ActionBarSherlockCompat @com.actionbarsherlock.ActionBarSherlock$Implementation(api=7, dpi=-1) 06-03 17:48:57.708: I/ActionBarSherlock (907): 使用限定符注册 ActionBarSherlockNative @com.actionbarsherlock.ActionBarSherlock$Implementation(api=14, dpi=-1) 06-03 17:48:57.748: I/ActionBarSherlock(907): 使用实现:ActionBarSherlockNative 06-03 17 :48:57.748:D/ActionBarSherlock(907):[]活动:com.example.pixelapp3.page3@412409f8,标志:1 06-03 17:48:57.758:D/ActionBarSherlock(907):[setContentView]视图: android.support.v4.view.ViewPager@41243fe0 06-03 17:48:57.779:D/ActionBarSherlock(907):[setContentView] 视图:android.support.v4.view.ViewPager@41243fe0,参数:android.view。 ViewGroup$LayoutParams@41252b70 06-03 17:48:57.858: D/dalvikvm(907):GC_CONCURRENT 释放 178K,3% 空闲 8291K/8519K,暂停 115ms+13ms,总共 305ms 06-03 17:48:57.858: D/dalvikvm(907): WAIT_FOR_CONCURRENT_GC 阻塞 54ms 06-03 17:48:57.908: D/ActionBarS 907): [getActionBar] 06-03 17:48:57.928: D/ActionBarSherlock(907): [getActionBar] 06-03 17:48:57.948: V/21st Polling:(907): clicked 06-03 17:48 :58.098: D/AndroidRuntime(907): 关闭 VM 06-03 17:48:58.098: W/dalvikvm(907): threadid=1: 线程退出未捕获异常 (group=0x40a13300) 06-03 17:48: 58.188: E/AndroidRuntime(907): 致命异常: main 06-03 17:48:58.188: E/AndroidRuntime(907): java.lang.ClassCastException: com.example.pixelapp3.page3a 无法转换为 android.support。 v4.app.Fragment 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.support.v4.app.Fragment.instantiate(Fragment.java:394) 06-03 17:48:58.188: E /Android运行时(907):在 com.example.pixelapp3.TabsAdapter.getItem(TabsAdapter.java:97) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.support.v4.app.FragmentPagerAdapter.instantiateItem(FragmentPagerAdapter.java: 97) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.support.v4.view.ViewPager.addNewItem(ViewPager.java:829) 06-03 17:48:58.188: E/AndroidRuntime( 907): 在 android.support.v4.view.ViewPager.populate(ViewPager.java:979) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.support.v4.view.ViewPager.populate (ViewPager.java:911) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1432) 06-03 17:48:58.188 : E/AndroidRuntime(907): 在 android.view.View.measure(View.java:15172) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewGroup.measureChildWithMargins(ViewGroup.爪哇:4816) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 06-03 17:48:58.188: E/AndroidRuntime(907): 在android.view.View.measure(View.java:15172) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.widget.LinearLayout.measureVertical(LinearLayout.java:833) 06-03 17: 48:58.188: E/AndroidRuntime(907): 在 android.widget.LinearLayout.onMeasure(LinearLayout.java:574) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.View.measure (View.java:15172) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4816) 06-03 17:48:58.188: E/AndroidRuntime (907): 在 android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 com.android.internal.policy.impl.PhoneWindow$DecorView。 onMeasure(电话窗口。java:2148) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.View.measure(View.java:15172) 06-03 17:48:58.188: E/AndroidRuntime(907) : 在 android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1850) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1102) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1275) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewRootImpl .doTraversal(ViewRootImpl.java:1000) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214) 06-03 17:48:58.188 : E/AndroidRuntime(907): 在 android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view。Choreographer.doCallbacks(Choreographer.java:555) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.Choreographer.doFrame(Choreographer.java:525) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.os.Handler.handleCallback(Handler .java:615) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.os.Handler.dispatchMessage(Handler.java:92) 06-03 17:48:58.188: E/AndroidRuntime(907 ): 在 android.os.Looper.loop(Looper.java:137) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 android.app.ActivityThread.main(ActivityThread.java:4745) 06- 03 17:48:58.188: E/AndroidRuntime(907): 在 java.lang.reflect.Method.invokeNative(Native Method) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 java.lang.reflect .Method.invoke(方法。java:511) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-03 17:48:58.188: E/AndroidRuntime(907): 在 dalvik.system.NativeStart.main (本机方法)

任何帮助将不胜感激。谢谢!

4

0 回答 0