android - tabStripEnabled for TabWidget in Older API's -
android 2.2 i.e api level 8 has tabstripenabled="true" tabwidget how achieve same in older versions of android?
private void setuptabs(tabhost tabhost) { linearlayout ll = (linearlayout) tabhost.getchildat(0); tabwidget tw = (tabwidget) ll.getchildat(0); field mbottomleftstrip; field mbottomrightstrip; try { mbottomleftstrip = tw.getclass().getdeclaredfield("mbottomleftstrip"); mbottomrightstrip = tw.getclass().getdeclaredfield("mbottomrightstrip"); if (!mbottomleftstrip.isaccessible()) { mbottomleftstrip.setaccessible(true); } if (!mbottomrightstrip.isaccessible()) { mbottomrightstrip.setaccessible(true); } mbottomleftstrip.set(tw, getresources().getdrawable(r.drawable.blank)); mbottomrightstrip.set(tw, getresources().getdrawable(r.drawable.blank));// blank name of image in drawable folder } catch (java.lang.nosuchfieldexception e) { // possibly 2.2 try { method stripenabled = tw.getclass().getdeclaredmethod("setstripenabled", boolean.class); stripenabled.invoke(tw, false); } catch (exception e1) { e1.printstacktrace(); } } catch (exception e) {} }
Comments
Post a Comment