我有一个ListView,当按下一行时,我想开始一个新的活动。列表视图位于选项卡中的片段显示中。我用来显示活动的代码是:
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
Intent intent = new Intent(mView.getContext(), SessionActivity.class);
startActivity(intent);
}
当我运行代码时,会显示新活动,但应用程序会立即崩溃。这是我在日志中得到的:
05-11 15:05:08.504: I/Process(1128): Sending signal. PID: 1128 SIG: 9
05-11 15:10:47.224: I/ActionBarSherlock(1178): Registering ActionBarSherlockCompat with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=7, dpi=-1)
05-11 15:10:47.224: I/ActionBarSherlock(1178): Registering ActionBarSherlockNative with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=14, dpi=-1)
05-11 15:10:47.234: I/ActionBarSherlock(1178): Using implementation: ActionBarSherlockNative
05-11 15:10:47.234: D/ActionBarSherlock(1178): [<ctor>] activity: com.hotrodsoftware.vgb.MainActivity@417808b0, flags: 1
05-11 15:10:47.234: D/ActionBarSherlock(1178): [setContentView] view: android.support.v4.view.ViewPager@417835d0
05-11 15:10:47.234: D/ActionBarSherlock(1178): [setContentView] view: android.support.v4.view.ViewPager@417835d0, params: android.view.ViewGroup$LayoutParams@4178d4c0
05-11 15:10:47.315: D/ActionBarSherlock(1178): [getActionBar]
05-11 15:10:47.324: D/ActionBarSherlock(1178): [getActionBar]
05-11 15:10:47.344: V/21st Polling:(1178): clicked
05-11 15:10:47.603: D/SherlockFragmentActivity(1178): [onCreatePanelMenu] featureId: 0, menu: com.android.internal.view.menu.MenuBuilder@417c37b8
05-11 15:10:47.613: D/dalvikvm(1178): GC_CONCURRENT freed 176K, 2% free 14334K/14599K, paused 6ms+5ms
05-11 15:10:47.613: D/ActionBarSherlock(1178): [dispatchCreateOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417c37b8
05-11 15:10:47.633: D/ActionBarSherlock(1178): [callbackCreateOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd5f8
05-11 15:10:47.633: D/Watson(1178): [onCreatePanelMenu] featureId: 0, menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd5f8
05-11 15:10:47.633: D/Watson(1178): [onCreatePanelMenu] activity create result: true
05-11 15:10:47.633: D/SherlockFragmentActivity(1178): [getSupportMenuInflater]
05-11 15:10:47.633: D/ActionBarSherlock(1178): [getMenuInflater]
05-11 15:10:47.633: D/ActionBarSherlock(1178): [getActionBar]
05-11 15:10:47.633: D/Watson(1178): [onCreatePanelMenu] fragments create result: false
05-11 15:10:47.633: D/Watson(1178): [onCreatePanelMenu] returning true
05-11 15:10:47.633: D/ActionBarSherlock(1178): [callbackCreateOptionsMenu] returning true
05-11 15:10:47.633: D/ActionBarSherlock(1178): [dispatchCreateOptionsMenu] returning true
05-11 15:10:47.633: D/SherlockFragmentActivity(1178): [onCreatePanelMenu] returning true
05-11 15:10:47.633: D/SherlockFragmentActivity(1178): [onPreparePanel] featureId: 0, view: null, menu: com.android.internal.view.menu.MenuBuilder@417c37b8
05-11 15:10:47.643: D/ActionBarSherlock(1178): [dispatchPrepareOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417c37b8
05-11 15:10:47.643: D/ActionBarSherlock(1178): [callbackPrepareOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd5f8
05-11 15:10:47.643: D/Watson(1178): [onPreparePanel] featureId: 0, view: null menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd5f8
05-11 15:10:47.643: D/Watson(1178): [onPreparePanel] activity prepare result: true
05-11 15:10:47.643: D/Watson(1178): [onPreparePanel] fragments prepare result: false
05-11 15:10:47.643: D/Watson(1178): [onPreparePanel] returning false
05-11 15:10:47.643: D/ActionBarSherlock(1178): [callbackPrepareOptionsMenu] returning false
05-11 15:10:47.643: D/ActionBarSherlock(1178): [dispatchPrepareOptionsMenu] returning false
05-11 15:10:47.643: D/SherlockFragmentActivity(1178): [onPreparePanel] returning false
05-11 15:10:47.683: D/gralloc_goldfish(1178): Emulator without GPU emulation detected.
05-11 15:10:51.543: V/21st Polling:(1178): clicked
05-11 15:10:53.154: D/AndroidRuntime(1178): Shutting down VM
05-11 15:10:53.154: W/dalvikvm(1178): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
05-11 15:10:53.244: E/AndroidRuntime(1178): FATAL EXCEPTION: main
05-11 15:10:53.244: E/AndroidRuntime(1178): java.lang.NullPointerException
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
05-11 15:10:53.244: E/AndroidRuntime(1178): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.Activity.performSaveInstanceState(Activity.java:1113)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1185)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2789)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2847)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.ActivityThread.access$900(ActivityThread.java:122)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1163)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.os.Looper.loop(Looper.java:137)
05-11 15:10:53.244: E/AndroidRuntime(1178): at android.app.ActivityThread.main(ActivityThread.java:4340)
05-11 15:10:53.244: E/AndroidRuntime(1178): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 15:10:53.244: E/AndroidRuntime(1178): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 15:10:53.244: E/AndroidRuntime(1178): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 15:10:53.244: E/AndroidRuntime(1178): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 15:10:53.244: E/AndroidRuntime(1178): at dalvik.system.NativeStart.main(Native Method)
05-11 15:12:19.614: I/ActionBarSherlock(1226): Registering ActionBarSherlockCompat with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=7, dpi=-1)
05-11 15:12:19.614: I/ActionBarSherlock(1226): Registering ActionBarSherlockNative with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=14, dpi=-1)
05-11 15:12:19.624: I/ActionBarSherlock(1226): Using implementation: ActionBarSherlockNative
05-11 15:12:19.624: D/ActionBarSherlock(1226): [<ctor>] activity: com.hotrodsoftware.vgb.MainActivity@417782f0, flags: 1
05-11 15:12:19.634: D/ActionBarSherlock(1226): [setContentView] view: android.support.v4.view.ViewPager@4177b010
05-11 15:12:19.634: D/ActionBarSherlock(1226): [setContentView] view: android.support.v4.view.ViewPager@4177b010, params: android.view.ViewGroup$LayoutParams@41784f00
05-11 15:12:19.714: D/ActionBarSherlock(1226): [getActionBar]
05-11 15:12:19.724: D/ActionBarSherlock(1226): [getActionBar]
05-11 15:12:19.744: V/21st Polling:(1226): clicked
05-11 15:12:20.023: D/SherlockFragmentActivity(1226): [onCreatePanelMenu] featureId: 0, menu: com.android.internal.view.menu.MenuBuilder@417bb1f8
05-11 15:12:20.023: D/ActionBarSherlock(1226): [dispatchCreateOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417bb1f8
05-11 15:12:20.033: D/ActionBarSherlock(1226): [callbackCreateOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd968
05-11 15:12:20.033: D/Watson(1226): [onCreatePanelMenu] featureId: 0, menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd968
05-11 15:12:20.033: D/Watson(1226): [onCreatePanelMenu] activity create result: true
05-11 15:12:20.033: D/SherlockFragmentActivity(1226): [getSupportMenuInflater]
05-11 15:12:20.033: D/ActionBarSherlock(1226): [getMenuInflater]
05-11 15:12:20.033: D/ActionBarSherlock(1226): [getActionBar]
05-11 15:12:20.043: D/Watson(1226): [onCreatePanelMenu] fragments create result: false
05-11 15:12:20.043: D/Watson(1226): [onCreatePanelMenu] returning true
05-11 15:12:20.043: D/ActionBarSherlock(1226): [callbackCreateOptionsMenu] returning true
05-11 15:12:20.043: D/ActionBarSherlock(1226): [dispatchCreateOptionsMenu] returning true
05-11 15:12:20.043: D/SherlockFragmentActivity(1226): [onCreatePanelMenu] returning true
05-11 15:12:20.043: D/SherlockFragmentActivity(1226): [onPreparePanel] featureId: 0, view: null, menu: com.android.internal.view.menu.MenuBuilder@417bb1f8
05-11 15:12:20.043: D/ActionBarSherlock(1226): [dispatchPrepareOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417bb1f8
05-11 15:12:20.043: D/ActionBarSherlock(1226): [callbackPrepareOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd968
05-11 15:12:20.053: D/Watson(1226): [onPreparePanel] featureId: 0, view: null menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417bd968
05-11 15:12:20.053: D/Watson(1226): [onPreparePanel] activity prepare result: true
05-11 15:12:20.053: D/Watson(1226): [onPreparePanel] fragments prepare result: false
05-11 15:12:20.053: D/Watson(1226): [onPreparePanel] returning false
05-11 15:12:20.063: D/ActionBarSherlock(1226): [callbackPrepareOptionsMenu] returning false
05-11 15:12:20.063: D/ActionBarSherlock(1226): [dispatchPrepareOptionsMenu] returning false
05-11 15:12:20.063: D/SherlockFragmentActivity(1226): [onPreparePanel] returning false
05-11 15:12:20.123: D/gralloc_goldfish(1226): Emulator without GPU emulation detected.
05-11 15:12:20.173: D/dalvikvm(1226): GC_CONCURRENT freed 156K, 2% free 14337K/14599K, paused 6ms+4ms
05-11 15:12:22.654: V/21st Polling:(1226): clicked
05-11 15:12:24.244: D/AndroidRuntime(1226): Shutting down VM
05-11 15:12:24.244: W/dalvikvm(1226): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
05-11 15:12:24.304: E/AndroidRuntime(1226): FATAL EXCEPTION: main
05-11 15:12:24.304: E/AndroidRuntime(1226): java.lang.NullPointerException
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
05-11 15:12:24.304: E/AndroidRuntime(1226): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.Activity.performSaveInstanceState(Activity.java:1113)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1185)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2789)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2847)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.ActivityThread.access$900(ActivityThread.java:122)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1163)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.os.Looper.loop(Looper.java:137)
05-11 15:12:24.304: E/AndroidRuntime(1226): at android.app.ActivityThread.main(ActivityThread.java:4340)
05-11 15:12:24.304: E/AndroidRuntime(1226): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 15:12:24.304: E/AndroidRuntime(1226): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 15:12:24.304: E/AndroidRuntime(1226): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 15:12:24.304: E/AndroidRuntime(1226): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 15:12:24.304: E/AndroidRuntime(1226): at dalvik.system.NativeStart.main(Native Method)
05-11 15:12:57.515: I/ActionBarSherlock(1274): Registering ActionBarSherlockCompat with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=7, dpi=-1)
05-11 15:12:57.515: I/ActionBarSherlock(1274): Registering ActionBarSherlockNative with qualifier @com.actionbarsherlock.ActionBarSherlock$Implementation(api=14, dpi=-1)
05-11 15:12:57.524: I/ActionBarSherlock(1274): Using implementation: ActionBarSherlockNative
05-11 15:12:57.524: D/ActionBarSherlock(1274): [<ctor>] activity: com.hotrodsoftware.vgb.MainActivity@417790e0, flags: 1
05-11 15:12:57.524: D/ActionBarSherlock(1274): [setContentView] view: android.support.v4.view.ViewPager@4177be00
05-11 15:12:57.524: D/ActionBarSherlock(1274): [setContentView] view: android.support.v4.view.ViewPager@4177be00, params: android.view.ViewGroup$LayoutParams@41785cf0
05-11 15:12:57.594: D/ActionBarSherlock(1274): [getActionBar]
05-11 15:12:57.604: D/ActionBarSherlock(1274): [getActionBar]
05-11 15:12:57.624: V/21st Polling:(1274): clicked
05-11 15:12:57.843: D/SherlockFragmentActivity(1274): [onCreatePanelMenu] featureId: 0, menu: com.android.internal.view.menu.MenuBuilder@417bbff0
05-11 15:12:57.843: D/ActionBarSherlock(1274): [dispatchCreateOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417bbff0
05-11 15:12:57.843: D/ActionBarSherlock(1274): [callbackCreateOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417be760
05-11 15:12:57.855: D/Watson(1274): [onCreatePanelMenu] featureId: 0, menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417be760
05-11 15:12:57.855: D/Watson(1274): [onCreatePanelMenu] activity create result: true
05-11 15:12:57.855: D/SherlockFragmentActivity(1274): [getSupportMenuInflater]
05-11 15:12:57.855: D/ActionBarSherlock(1274): [getMenuInflater]
05-11 15:12:57.855: D/ActionBarSherlock(1274): [getActionBar]
05-11 15:12:57.855: D/Watson(1274): [onCreatePanelMenu] fragments create result: false
05-11 15:12:57.863: D/Watson(1274): [onCreatePanelMenu] returning true
05-11 15:12:57.863: D/ActionBarSherlock(1274): [callbackCreateOptionsMenu] returning true
05-11 15:12:57.863: D/ActionBarSherlock(1274): [dispatchCreateOptionsMenu] returning true
05-11 15:12:57.863: D/SherlockFragmentActivity(1274): [onCreatePanelMenu] returning true
05-11 15:12:57.863: D/SherlockFragmentActivity(1274): [onPreparePanel] featureId: 0, view: null, menu: com.android.internal.view.menu.MenuBuilder@417bbff0
05-11 15:12:57.863: D/ActionBarSherlock(1274): [dispatchPrepareOptionsMenu] menu: com.android.internal.view.menu.MenuBuilder@417bbff0
05-11 15:12:57.863: D/ActionBarSherlock(1274): [callbackPrepareOptionsMenu] menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417be760
05-11 15:12:57.863: D/Watson(1274): [onPreparePanel] featureId: 0, view: null menu: com.actionbarsherlock.internal.view.menu.MenuWrapper@417be760
05-11 15:12:57.863: D/Watson(1274): [onPreparePanel] activity prepare result: true
05-11 15:12:57.863: D/Watson(1274): [onPreparePanel] fragments prepare result: false
05-11 15:12:57.863: D/Watson(1274): [onPreparePanel] returning false
05-11 15:12:57.873: D/ActionBarSherlock(1274): [callbackPrepareOptionsMenu] returning false
05-11 15:12:57.873: D/ActionBarSherlock(1274): [dispatchPrepareOptionsMenu] returning false
05-11 15:12:57.873: D/SherlockFragmentActivity(1274): [onPreparePanel] returning false
05-11 15:12:57.953: D/gralloc_goldfish(1274): Emulator without GPU emulation detected.
05-11 15:12:57.963: D/dalvikvm(1274): GC_CONCURRENT freed 159K, 2% free 14337K/14599K, paused 6ms+4ms
05-11 15:12:59.184: V/21st Polling:(1274): clicked
05-11 15:13:00.913: D/AndroidRuntime(1274): Shutting down VM
05-11 15:13:00.913: W/dalvikvm(1274): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
05-11 15:13:00.963: E/AndroidRuntime(1274): FATAL EXCEPTION: main
05-11 15:13:00.963: E/AndroidRuntime(1274): java.lang.NullPointerException
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:1576)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1617)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:481)
05-11 15:13:00.963: E/AndroidRuntime(1274): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.Activity.performSaveInstanceState(Activity.java:1113)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1185)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:2789)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2847)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.ActivityThread.access$900(ActivityThread.java:122)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1163)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.os.Handler.dispatchMessage(Handler.java:99)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.os.Looper.loop(Looper.java:137)
05-11 15:13:00.963: E/AndroidRuntime(1274): at android.app.ActivityThread.main(ActivityThread.java:4340)
05-11 15:13:00.963: E/AndroidRuntime(1274): at java.lang.reflect.Method.invokeNative(Native Method)
05-11 15:13:00.963: E/AndroidRuntime(1274): at java.lang.reflect.Method.invoke(Method.java:511)
05-11 15:13:00.963: E/AndroidRuntime(1274): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-11 15:13:00.963: E/AndroidRuntime(1274): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-11 15:13:00.963: E/AndroidRuntime(1274): at dalvik.system.NativeStart.main(Native Method)
如果它有任何区别我在我的应用程序中使用ActionBarSherlock库。
答案 0 :(得分:0)
如果在another question on SO中找到解决方案。在我的TabsAdapter中,我正在扩展FragmentPageAdapter
。我必须更改它以扩展FragmentStatePagerAdapter
并解决问题。
感谢提示@Secran Ozdemir,这帮助我找到了问题。