How to find tab host in its sub activity in Android? -
i creating custom tabhost , on each tab spec open different activity . want tab host on sub activity finding linear layout on tab host screen.
select_item.xml (tab host layout)
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <include android:id="@+id/include1" android:layout_width="fill_parent" android:layout_height="wrap_content" layout="@layout/outcom_actionbar" > </include> <tabhost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <view android:layout_width="fill_parent" android:layout_height="0.5dip" android:background="#fff" /> <tabwidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginleft="0dip" android:layout_marginright="0dip" /> <view android:layout_width="fill_parent" android:layout_height="2dip" android:background="#696969" /> <view android:layout_width="fill_parent" android:layout_height="2dip" android:background="#add23b" /> <framelayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </linearlayout> </tabhost> </linearlayout> selectitem.java (custom tab host)
public class selectitem extends tabactivity { private tabhost mtabhost; private void setuptabhost() { mtabhost = (tabhost) findviewbyid(android.r.id.tabhost); mtabhost.setup(); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.select_item); context=this; setuptabhost(); mtabhost.gettabwidget().setdividerdrawable(null); setuptab(new textview(this), getstring(r.string.positions),constants.activityname.positions.tostring()); setuptab(new textview(this), getstring(r.string.sever),constants.activityname.sever.tostring()); } private void setuptab(final view view, final string tag,final string activityname) { view tabview = createtabview(mtabhost.getcontext(), tag); tabspec setcontent = mtabhost.newtabspec(tag).setindicator(tabview).setcontent(new tabcontentfactory() { public view createtabcontent(string tag) {return view;} }); intent intent =null; if(activityname.comparetoignorecase(constants.activityname.positions.tostring())==0) intent = new intent().setclass(this, items.class); else if(activityname.comparetoignorecase(constants.activityname.sever.tostring())==0) intent = new intent().setclass(this, sever.class); intent.putextra(constants.project_id, projectid); setcontent.setcontent(intent); mtabhost.addtab(setcontent); } private static view createtabview(final context context, final string text) { view view = layoutinflater.from(context).inflate(r.layout.tabs_bg, null); textview tv = (textview) view.findviewbyid(r.id.tabstext); tv.settext(text); return view; } } on server activity want view of linearlayout of select_item.xml file. able details of tab host in sever activity.
please suggest me usable link or sample code.
here example may out. click here @ link , check out project on github. helped me out.
Comments
Post a Comment