firebase - Calling context in a FirebaseListAdapter (Android) -
i created tabbed activity contains 3 fragments. nullpointerexception whenever scroll listfragment used firebaselistadapter. suspect has context parameter in firebaselistadapter. read in other posts getactivity()
should used on fragments didn't work in case.
here's fragment class catches error:
public class actionplan extends listfragment { public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view rootview = inflater.inflate(r.layout.activity_action_plan, container, false); getactionplan(rootview); return rootview; } public void getactionplan(final view view){ firebase ref = new firebase("https://infotrack.firebaseio.com/infotrack/rso/actionplan"); listview ap = (listview) view.findviewbyid(r.id.list); firebaselistadapter<apcontent> apadapter = new firebaselistadapter<apcontent>(getactivity(), apcontent.class, r.layout.layout_action_plan, ref) { @override protected void populateview(view view, apcontent content, int position) { ((textview) view.findviewbyid(r.id.txtactivity)).settext(content.getactivity()); ((textview) view.findviewbyid(r.id.txttimeframe)).settext("timeframe: " +content.gettimeframe()); ((textview) view.findviewbyid(r.id.txtcorevalues)).settext("core values: " +content.getcorevalues()); ((textview) view.findviewbyid(r.id.txtobjective)).settext("objective: " +content.getobjective()); ((textview) view.findviewbyid(r.id.txtstrategy)).settext("strategy: " +content.getstrategy()); ((textview) view.findviewbyid(r.id.txtmanpower)).settext("manpower: " +content.getmanpower()); ((textview) view.findviewbyid(r.id.txtbudget)).settext("budget proposal: " +content.getbudget()); } }; ap.setadapter(apadapter); }
}
stacktrace:
e/androidruntime: fatal exception: main java.lang.nullpointerexception @ xyz.kimfeliciano.infotrack.infotrack.actionplan.getactionplan(actionplan.java:47) @ xyz.kimfeliciano.infotrack.infotrack.actionplan.oncreateview(actionplan.java:20) @ android.support.v4.app.fragment.performcreateview(fragment.java:1789) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:955) @ android.support.v4.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1138) @ android.support.v4.app.backstackrecord.run(backstackrecord.java:740) @ android.support.v4.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1501) @ android.support.v4.app.fragmentmanagerimpl.executependingtransactions(fragmentmanager.java:490) @ android.support.v4.app.fragmentpageradapter.finishupdate(fragmentpageradapter.java:141) @ android.support.v4.view.viewpager.populate(viewpager.java:1105) @ android.support.v4.view.viewpager.populate(viewpager.java:951) @ android.support.v4.view.viewpager$3.run(viewpager.java:250) @ android.view.choreographer$callbackrecord.run(choreographer.java:725) @ android.view.choreographer.docallbacks(choreographer.java:555) @ android.view.choreographer.doframe(choreographer.java:524) @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711) @ android.os.handler.handlecallback(handler.java:615) @ android.os.handler.dispatchmessage(handler.java:92) @ android.os.looper.loop(looper.java:213) @ android.app.activitythread.main(activitythread.java:4787) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:511) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:789) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:556) @ dalvik.system.nativestart.main(native method)
the error points @ these lines: ap.setadapter(apadapter);
, getactionplan(rootview);
it seems r.id.list
not being found on current layout. sure it's there?
Comments
Post a Comment