android - ListFragment not displaying async data -
i using loopj asynchronously load json data listfragment. using default listview comes listfragment , calling method filllistview in loopj's onsuccess callback function. have looked around @ many similar postings issue cannot resolve mine.
i have tried loading listfragment mainactivity calling
menucatfragment.newinstance("a","c").setlistadapter(adapter);
but not working too.
can please help.
public class menucatfragment extends listfragment {
//android studio auto-generated code ommitted public menucatfragment() { }
@override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); if (getarguments() != null) { mparam1 = getarguments().getstring(arg_param1); mparam2 = getarguments().getstring(arg_param2); } myapp = (app)this.getactivity().getapplication(); currentrestosummary = myapp.getselectedrestosummary(); restoid = currentrestosummary.getrestoid(); try { loadselectedresto(); } catch (exception e) { } } private void loadselectedresto() throws jsonexception { eatnowrestclient.get("resto", new requestparams("id", restoid), new jsonhttpresponsehandler() { @override public void onsuccess(int statuscode, header[] headers, jsonobject response) { gson gson = new gson(); type listtype = new typetoken<resto>() {}.gettype(); try { resto = gson.fromjson(response.tostring(), listtype); myapp.setselectedresto(resto); filllistview(); //progressdialog.dismiss(); } catch (exception e) { throw e; } } @override public void onfailure(int statuscode, header[] headers, throwable throwable, jsonobject errorresponse) { super.onfailure(statuscode, headers, throwable, errorresponse); //progressdialog.dismiss(); //log.d("failed: ", ""+statuscode); //log.d("error : ", "" + throwable); } }); private void filllistview() { listadapter adapter; adapter = new customadaptermenucat(getactivity(),r.layout.custom_row_menucat,resto.getmenu_categories()); setlistadapter(adapter); } } //adapter code public class customadaptermenucat extends arrayadapter<menucategory> { menucategory[] menucat; context c; public customadaptermenucat(context context, int resource, menucategory[] objects) { super(context, resource, objects); menucat = objects; c = context; } @override public int getcount() { return menucat.length; } @override public menucategory getitem(int position) { return menucat[position]; } @override public long getitemid(int position) { return position; } @override public view getview(int position, view convertview, viewgroup parent) { view customview = view.inflate(c, r.layout.custom_row_menucat,null); textview lblmenucatnameresto = (textview)customview.findviewbyid(r.id.lblmenucat); lblmenucatnameresto.settext(menucat[position].getname()); return customview; }
}
i found solution...the issue fragmenttabhost layout xml...below working one.
<android.support.v4.app.fragmenttabhost android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/tabresto"> <framelayout android:id="@android:id/tabcontent" android:layout_width="match_parent" android:layout_height="wrap_content" /> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <tabwidget android:id="@android:id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"/> <framelayout android:id="@+id/realtabcontent" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1"/> </linearlayout> </android.support.v4.app.fragmenttabhost>
Comments
Post a Comment