java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rada.radastaff/com.rada.radastaff.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ToggleButton.setChecked(boolean)' on a null object reference

Stack Overflow | TruongHieu | 7 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Can't handle Toggle Button on Actionbar

    Stack Overflow | 7 months ago | TruongHieu
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rada.radastaff/com.rada.radastaff.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ToggleButton.setChecked(boolean)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'void android.widget.ToggleButton.setChecked(boolean)' on a null object reference

      at com.rada.radastaff.MainActivity.onCreate()
    2. com.rada.radastaff
      MainActivity.onCreate
      1. com.rada.radastaff.MainActivity.onCreate(MainActivity.java:20)
      1 frame
    3. Android Platform
      ActivityThread.main
      1. android.app.Activity.performCreate(Activity.java:5975)
      2. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
      3. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
      4. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
      5. android.app.ActivityThread.access$800(ActivityThread.java:147)
      6. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
      7. android.os.Handler.dispatchMessage(Handler.java:102)
      8. android.os.Looper.loop(Looper.java:135)
      9. android.app.ActivityThread.main(ActivityThread.java:5253)
      9 frames
    4. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames