android - Custom TabHost / TabSpec don't work -


i've little problem in initialisetabhost(). when give drawable in setindicator, it's don't work.

tabactivity's deprecated, use fragmentactivity. tutorial don't how custom indicator.

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     // step 1: inflate layout     setcontentview(r.layout.evenement);     // step 2: setup tabhost     initialisetabhost(savedinstancestate);     if (savedinstancestate != null) {         mtabhost.setcurrenttabbytag(savedinstancestate.getstring("tab")); //set tab per saved state     } }  protected void onsaveinstancestate(bundle outstate) {     outstate.putstring("tab", mtabhost.getcurrenttabtag()); //save tab selected     super.onsaveinstancestate(outstate); }  private void initialisetabhost(bundle args) {     mtabhost = (tabhost) findviewbyid(android.r.id.tabhost);     mtabhost.setup();     tabinfo tabinfo = null;     fragmentlistevents.addtab(this, this.mtabhost, this.mtabhost.newtabspec("after").setindicator("",             getresources().getdrawable(r.drawable.tab_bg_selector)), (tabinfo = new tabinfo("after", event_after.class, args)));     this.maptabinfo.put(tabinfo.tag, tabinfo);     fragmentlistevents.addtab(this, this.mtabhost, this.mtabhost.newtabspec("before").setindicator("before"), (tabinfo = new tabinfo("before", event_before.class, args)));     this.maptabinfo.put(tabinfo.tag, tabinfo);      // default first tab     this.ontabchanged("tab1");     //     mtabhost.setontabchangedlistener(this); } 

tab_bg_selector

<?xml version="1.0" encoding="utf-8"?>  <selector xmlns:android="http://schemas.android.com/apk/res/android">      <!--  active tab -->      <item android:state_selected="true" android:state_focused="false"          android:state_pressed="false" android:drawable="@drawable/tab_bg_selected" />      <!--  inactive tab -->      <item android:state_selected="false" android:state_focused="false"          android:state_pressed="false" android:drawable="@drawable/tab_bg_unselected" />      <!--  pressed tab -->      <item android:state_pressed="true" android:drawable="@android:color/transparent" />      <!--  selected tab (using d-pad) -->      <item android:state_focused="true" android:state_selected="true"          android:state_pressed="false" android:drawable="@android:color/transparent" />    </selector>

tab_bg_selected

<?xml version="1.0" encoding="utf-8"?>  <shape xmlns:android="http://schemas.android.com/apk/res/android"      android:shape="rectangle">      <gradient android:startcolor="#607f2f"          android:endcolor="#99c357" android:angle="-90" />  </shape>

thx answers.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -