android - Can't close Drawe in OnClickListener in my Adapter -
i can't close drawer in onclicklistener in adapter here onclicklistener
private view.onclicklistener click=new view.onclicklistener(){ @override public void onclick(view v) { intent = new intent(); drlay.closedrawers(); // error !!! switch(getposition()) { case 1: i.setcomponent(new componentname(contxt,top.class)); i.setaction("android.intent.action.main"); i.addcategory("android.intent.category.launcher"); i.addcategory("android.intent.category.default"); v.getcontext().startactivity(i); break;}
here logcat
fatal exception: main java.lang.nullpointerexception @ com.example.myapplication.myadapter$viewholder$1.onclick(myadapter.java:77) @ android.view.view.performclick(view.java:4240) @ android.view.view$performclick.run(view.java:17735) @ android.os.handler.handlecallback(handler.java:730) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:137) @ android.app.activitythread.main(activitythread.java:5136) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:525) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:737) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:553) @ dalvik.system.nativestart.main(native method)
how can close it?
your adapter cannot find drawer layout.
such things shouldn't handled in adapter though try moving listener activity hosting drawer , instead use setonitemclicklistener on list view.
Comments
Post a Comment