引起:第二个活动中的java.lang.NullPointerException onPageChangeListener

时间:2013-02-17 23:00:11

标签: android android-activity nullpointerexception

我有这个问题,在第二个活动中findviewbyId工作不正常,我有这个日志:

02-17 23:36:42.321: E/AndroidRuntime(616): FATAL EXCEPTION: main
02-17 23:36:42.321: E/AndroidRuntime(616): java.lang.RuntimeException: Unable to resume activity {it.polito.elite.make_rules/it.polito.elite.make_rules.SlideActivity}: java.lang.NullPointerException
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2575)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2603)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2089)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.os.Looper.loop(Looper.java:137)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.main(ActivityThread.java:4745)
02-17 23:36:42.321: E/AndroidRuntime(616):  at java.lang.reflect.Method.invokeNative(Native Method)
02-17 23:36:42.321: E/AndroidRuntime(616):  at java.lang.reflect.Method.invoke(Method.java:511)
02-17 23:36:42.321: E/AndroidRuntime(616):  at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
02-17 23:36:42.321: E/AndroidRuntime(616):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
02-17 23:36:42.321: E/AndroidRuntime(616):  at dalvik.system.NativeStart.main(Native Method)
02-17 23:36:42.321: E/AndroidRuntime(616): Caused by: java.lang.NullPointerException
02-17 23:36:42.321: E/AndroidRuntime(616):  at it.polito.elite.make_rules.adapter.ViewPagerChangeListener.exisistingRuleManagement(ViewPagerChangeListener.java:134)
02-17 23:36:42.321: E/AndroidRuntime(616):  at it.polito.elite.make_rules.adapter.ViewPagerChangeListener.onPageSelected(ViewPagerChangeListener.java:62)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:546)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:524)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:495)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:476)
02-17 23:36:42.321: E/AndroidRuntime(616):  at it.polito.elite.make_rules.SlideActivity.onResume(SlideActivity.java:203)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1184)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.Activity.performResume(Activity.java:5082)
02-17 23:36:42.321: E/AndroidRuntime(616):  at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2565)
02-17 23:36:42.321: E/AndroidRuntime(616):  ... 12 more
02-17 23:36:42.510: D/dalvikvm(616): GC_CONCURRENT freed 207K, 5% free 6266K/6535K, paused 24ms+35ms, total 239ms

在ViewPagerChangeListener.java:134行

LinearLayout fragmentMakeRule =(LinearLayout)fragmentExistingRule.findViewById(R.id.containerLayoutExistingRule);

主要是我:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_swipe);

你有什么想法吗?

0 个答案:

没有答案