我是Android编程的新手。而现在,我正在用android练习基本元素。我成功地创建了链接到其他活动的按钮,并以单独的方式创建了滑动选项卡。
现在,麻烦的是,当我尝试合并那些2时,我很难这样做。
根据eclipse,编码中没有警告或错误,但是当我点击应该用swipeytabs显示活动的按钮时,应用程序会关闭。
这里是logCat内容:
06-03 17:48:57.678:I / ActionBarSherlock(907):使用限定符@ com.actionbarsherlock.ActionBarSherlock $ Implementation(api = 7,dpi = -1)注册ActionBarSherlockCompat 06-03 17:48:57.708:I / ActionBarSherlock(907):使用限定符@ com.actionbarsherlock.ActionBarSherlock $ Implementation(api = 14,dpi = -1)注册ActionBarSherlockNative 06-03 17:48:57.748:I / ActionBarSherlock(907):使用实现:ActionBarSherlockNative 06-03 17:48:57.748:D / ActionBarSherlock(907):[] activity:com.example.pixelapp3.page3@412409f8,flags: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] view:android.support.v4.view.ViewPager@41243fe0,params: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 / ActionBarSherlock(907):[getActionBar] 06-03 17:48:57.928:D / ActionBarSherlock(907):[getActionBar] 06-03 17:48:57.948:V / 21轮询:(907):点击 06-03 17:48:58.098:D / AndroidRuntime(907):关闭VM 06-03 17:48:58.098:W / dalvikvm(907):threadid = 1:线程退出未捕获异常(组= 0x40a13300) 06-03 17:48:58.188:E / AndroidRuntime(907):致命异常:主要 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 / AndroidRuntime(907):at 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.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):在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):at com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.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):at java.lang.reflect.Method.invokeNative(Native Method) 06-03 17:48:58.188:E / AndroidRuntime(907):at java.lang.reflect.Method.invoke(Method.java:511) 06-03 17:48:58.188:E / AndroidRuntime(907):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:786) 06-03 17:48:58.188:E / AndroidRuntime(907):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 06-03 17:48:58.188:E / AndroidRuntime(907):at dalvik.system.NativeStart.main(Native Method)
非常感谢任何帮助。谢谢!