java.lang.NullPointerException: Attempt to invoke virtual method ‘void android.widget.RadioGroup.set

报错log

	E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.hgfenis.radiogroupdemo01, PID: 7180
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hgfenis.radiogroupdemo01/com.hgfenis.radiogroupdemo01.RadioGroupActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RadioGroup.setOnCheckedChangeListener(android.widget.RadioGroup$OnCheckedChangeListener)' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2668)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6198)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.RadioGroup.setOnCheckedChangeListener(android.widget.RadioGroup$OnCheckedChangeListener)' on a null object reference
        at com.hgfenis.radiogroupdemo01.RadioGroupActivity.onCreate(RadioGroupActivity.java:31)
        at android.app.Activity.performCreate(Activity.java:6692)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2621)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2729) 
        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1480) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6198) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781) 

报错行代码

radiogroup.setOnCheckedChangeListener(this);

解决办法:


(尚未解决)


上一篇:Android Activity——启动过程探索(一)


下一篇:Apache的HttpClient调用Https忽略证书校验