java - Android - Custom Array Adapter Not called During In and Out of a Fragment -
got stock problem couple of days now, have launchpadsectionfragment
fragment a, on onclick event fragment(b
) separate class called named videoplayerfragment
that extends listfragment
being called , displayed.
the problem:
when click fragment opens fragment b, inside fragment b contains listview - populated loadallproducts
database, in on oncreateview()
calls custom array adapter loads returned records in listview. fragment b displays blank screen if go previous fragment(a) goes b, displays listview. if lucky, first time frag b loads, show listview. i've been struggling this. thank considering.
public class collectiondemoactivity extends fragmentactivity { public static class demoobjectfragment extends fragment { public static class launchpadsectionfragment extends listfragment { //onclick event opens class //extends fragment list fragmenttransaction transaction = getchildfragmentmanager().begintransaction(); transaction.replace(r.id.contentfragment, fragment1, fragmaingroups ); transaction.addtobackstack(fragmaingroups); transaction.commit(); } } }
videoplayerfragment.java
public class videoplayerfragment extends listfragment { public void oncreate(bundle e){ super.oncreate(e); productslist = new arraylist<hashmap<string, ?>>(); db = new databasehandler(getactivity().getbasecontext()); mcontext = getactivity(); log.d("inside", "oncreate"); //this task populate data database //i checked in logcat , there rows returned. loadallproducts task = new loadallproducts(); task.execute(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { //this custom array adapter not called, not //it happens, not sure reason. put displays //logs , execute code, not. mysimplearrayadapter adapter = new mysimplearrayadapter( mcontext, productslist,r.layout.load_groups_activity_listview, foldernamegroups, selectedid); setlistadapter(adapter); }
}
thanks @luksprog, giving me hint. make sure custom array adapter called inside listfragment
, have put mysimplearrayadapter
inside onpostexecute()
on asynctask
make sure executed after dobackground()
Comments
Post a Comment