How to set Tab View Indicator background color in Android -
how change color on click tab host. can change image color not change.
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tabhost tabhost=(tabhost)findviewbyid(r.id.tabhost); tabhost.setup(); tabspec spec1=tabhost.newtabspec("tab 1"); spec1.setcontent(r.id.tab1);`enter code here` spec1.setindicator("tab 1", getresources().getdrawable(setbackgroundcolor(color.red)); tabspec spec2=tabhost.newtabspec("tab 2"); spec2.setindicator("tab 2", getresources().getdrawable(setbackgroundcolor(color.grean)); spec2.setcontent(r.id.tab2); tabspec spec3=tabhost.newtabspec("tab 3"); spec3.setindicator("tab 3", getresources().getdrawable(setbackgroundcolor(color.black)); spec3.setcontent(r.id.tab3); tabhost.addtab(spec1); tabhost.addtab(spec2); tabhost.addtab(spec3); } }
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tabhost tabhost=(tabhost)findviewbyid(r.id.tabhost); tabhost.setup(); tabspec spec1=tabhost.newtabspec("tab 1"); spec1.setcontent(r.id.tab1);`enter code here` spec1.setindicator("tab 1", getresources().getdrawable(setbackgroundcolor(view.color.red)); tabspec spec2=tabhost.newtabspec("tab 2"); spec2.setindicator("tab 2", getresources().getdrawable(setbackgroundcolor(view.color.grean)); spec2.setcontent(r.id.tab2); tabspec spec3=tabhost.newtabspec("tab 3"); spec3.setindicator("tab 3", getresources().getdrawable(setbackgroundcolor(view.color.black)); spec3.setcontent(r.id.tab3); tabhost.addtab(spec1); tabhost.addtab(spec2); tabhost.addtab(spec3); } }
Comments
Post a Comment