我试图在我的片段类中调用resume活动但是我收到以下错误
@Override
public void onResume() {
super.onResume();
getActivity().setContentView(R.layout.start_gps);
task.update();
}
这是错误
01-27 00:53:52.138: E/AndroidRuntime(29010): FATAL EXCEPTION: main
01-27 00:53:52.138: E/AndroidRuntime(29010): java.lang.NullPointerException
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.lifesymb.gps.StartActivity.onResume(StartActivity.java:137)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.Fragment.performResume(Fragment.java:1521)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:963)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Handler.handleCallback(Handler.java:725)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Handler.dispatchMessage(Handler.java:92)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.os.Looper.loop(Looper.java:158)
01-27 00:53:52.138: E/AndroidRuntime(29010): at android.app.ActivityThread.main(ActivityThread.java:5751)
01-27 00:53:52.138: E/AndroidRuntime(29010): at java.lang.reflect.Method.invokeNative(Native Method)
01-27 00:53:52.138: E/AndroidRuntime(29010): at java.lang.reflect.Method.invoke(Method.java:511)
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
01-27 00:53:52.138: E/AndroidRuntime(29010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
01-27 00:53:52.138: E/AndroidRuntime(29010): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
问题可能出在task
变量上,您可能没有重新/初始化它。设置内容视图应该在onCreate中完成,你不需要在简历中进行