java - Layout inflater is null -
can me? don't know why have javanullexepction in layoutinflater.here code :
this code in fragment :
servicemanager.getinstance().getcampaign( new callback <campaign>() { @override public void success(campaign campaign, response response) { campaigns = campaign; adapter = new recyclercampaignadapter(getactivity(), campaign); recyclerview.setadapter(adapter); recyclerview.additemdecoration(new horizontaldivideritemdecoration.builder(getactivity()).marginprovider(adapter).showlastdivider().build()); adapter.notifydatasetchanged(); if (progressbar.isshown()) { progressbar.setvisibility(view.invisible); } } @override public void failure(retrofiterror retrofiterror) { toast.maketext(getactivity(), "failed" + retrofiterror, toast.length_short).show(); progressbar.setvisibility(view.gone); } });
here code in adapter :
public recyclercampaignadapter (activity activity, campaign campaignlist) { this.activity = activity; this.campaignlist = campaignlist; this.inflater= layoutinflater.from(activity); }
i think getactivity() == null
don't know how can fix it.
java.lang.nullpointerexception @ android.view.layoutinflater.from(layoutinflater.java:212) @ tr.org.yyd.yeryuzudoktorlari.adapter.recyclercampaignadapter.(recyclercampaignadapter.java:38) @ tr.org.yyd.yeryuzudoktorlari.fragment.campaignfragment$1.success(campaignfragment.java:69) @ tr.org.yyd.yeryuzudoktorlari.fragment.campaignfragment$1.success(campaignfragment.java:65) @ retrofit.callbackrunnable$1.run(callbackrunnable.java:45) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:146) @ android.app.activitythread.main(activitythread.java:5756) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1291) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1107) @ dalvik.system.nativestart.main(native method)
edit: use replace method on frgment transaction when user clicks on item menu.so campaignfragment works okey when user clicks in first time crashes when user clicks again while still on. if change fragment , come campaginfragment there no crash.
the answer that.i don't know how fix worked.it's control.
if (getactivity() != null) { adapter = ....
Comments
Post a Comment