android - How to change colour in TabHost -
i doing application tabhost formate, tab displaying default color, there possibility change default color our own color.? got ideas google,
tabhost.setontabchangedlistener(new ontabchangelistener(){ @override public void ontabchanged(string tabid) { // todo auto-generated method stub for(int i=0;i<tabhost.gettabwidget().getchildcount();i++) { tabhost.gettabwidget().getchildat(i).setbackgroundcolor(r.color.transparent); //unselected } tabhost.gettabwidget().getchildat(tabhost.getcurrenttab()).setbackgroundcolor(color.parsecolor("#000011")); // selected }
whenever doing getting force close error. if having idea of changing background color, pls guide me.
you need first change default appearence
for(int i=0;i<tabhost.gettabwidget().getchildcount();i++) { if (i == 0) tabhost.gettabwidget().getchildat(i).setbackgroundcolor(color.parsecolor("#ffffff")); else tabhost.gettabwidget().getchildat(i).setbackgroundcolor(color.parsecolor("#7392b5")); }
before dealing ontabchanged
event
tabhost.setontabchangedlistener(new ontabchangelistener(){ @override public void ontabchanged(string tabid) { // todo auto-generated method stub for(int i=0;i<tabhost.gettabwidget().getchildcount();i++) { tabhost.gettabwidget().getchildat(i).setbackgroundcolor(color.parsecolor("#7392b5")); //unselected } tabhost.gettabwidget().getchildat(tabhost.getcurrenttab()).setbackgroundcolor(color.parsecolor("#ffffff")); // selected } });
Comments
Post a Comment