android - Listview inside SherlockFragment On Load. Layout not inflating -
here sample setup
splashscreen --> points mainactivity --> 2 tabs (tab1 , tab2) need inflate listview in tab1.
here codes.
from splashscreen (works ok)
protected void onpostexecute(void result) { // todo auto-generated method stub intent = new intent(splashscreen.this, mainactivity.class); startactivity(i); }
mainactivity.java (works ok - loads 2 tabs @ top )
public class mainactivity extends sherlockfragmentactivity { public static string active_tab = "activetab"; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // setcontentview(r.layout.categories_list); apprater.displayask2rate(this, 7, 1, false); getsupportactionbar().settitle("keto recipes"); getsupportactionbar().setsubtitle("ketozen.com"); final actionbar actionbar = getsupportactionbar(); actionbar.setnavigationmode(actionbar.navigation_mode_tabs); // add tabs tab tab1 = actionbar .newtab() .settext("art") .settablistener( new tablistener<tabfragment>(this, "tab1", tabfragment.class)); actionbar.addtab(tab1); tab tab2 = actionbar .newtab() .settext("science") .settablistener( new tablistener<tabfragment1>(this, "tab2", tabfragment1.class)); actionbar.addtab(tab2); // check if there saved state select active tab if (savedinstancestate != null) { getsupportactionbar().setselectednavigationitem( savedinstancestate.getint(active_tab)); } }
tabfragment.java ( 1 st tab listview supposed load. not working)
public class tabfragment extends sherlockfragment { @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view view = inflater.inflate(r.layout.categories_list, container, false); // view initialization here return view; }
}
here categories_list xml
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/lytcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/background"> <com.google.ads.adview xmlns:googleads="http://schemas.android.com/apk/lib/com.google.ads" android:id="@+id/ads" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/background" googleads:adsize="smart_banner" googleads:adunitid="@string/admob_id" android:layout_alignparentbottom="true" /> <listview android:id="@+id/listcategories" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_above="@+id/ads" android:layout_below="@+id/lyttitlebar" android:divider="@color/separator" android:dividerheight="1dp" android:fadescrollbars="true" android:fadingedge="none" android:fastscrollenabled="true" /> <textview android:id="@+id/txtalert" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/alert" android:textcolor="@color/text" android:textsize="14sp" android:layout_centerinparent="true" android:visibility="gone"/>
any ideas please.
i think tutorial you
http://neilgoodman.net/2012/03/12/working-with-fragments-on-android-part-2/
Comments
Post a Comment