java - Checkbox in the popupMenu -
i have popupmenu , checkbox. need make write status checkbox boolean. code not working:
menuitem fast_result; boolean fast=false; @override public boolean onoptionsitemselected(menuitem item) { int id = item.getitemid(); switch (id) { case r.id.fastresult: fast_result = item.getsubmenu().getitem(r.id.fastresult);//this 182 line fast_result.setchecked(!fast_result.ischecked()); fast=fast_result.ischecked(); return true; } }
it errors:
fatal exception: main java.lang.nullpointerexception @ com.alexvsalex.helpformath.rootsactivity.onoptionsitemselected(rootsactivity.java:182) @ android.app.activity.onmenuitemselected(activity.java:2502) @ com.android.internal.policy.impl.phonewindow.onmenuitemselected(phonewindow.java:950) @ com.android.internal.view.menu.menubuilder.dispatchmenuitemselected(menubuilder.java:735) @ com.android.internal.view.menu.menuitemimpl.invoke(menuitemimpl.java:149) @ com.android.internal.view.menu.menubuilder.performitemaction(menubuilder.java:874) @ com.android.internal.view.menu.listmenupresenter.onitemclick(listmenupresenter.java:163) @ android.widget.adapterview.performitemclick(adapterview.java:292) @ android.widget.abslistview.performitemclick(abslistview.java:1058) @ android.widget.abslistview$performclick.run(abslistview.java:2514) @ android.widget.abslistview$1.run(abslistview.java:3168) @ android.os.handler.handlecallback(handler.java:605) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:4424) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) @ dalvik.system.nativestart.main(native method)
what do?
the problem solved:
case r.id.fastresult: fast_result = item; //there error fast_result.setchecked(!fast_result.ischecked()); fast=fast_result.ischecked(); return true;
Comments
Post a Comment