Thursday, 4 April 2013

Change Tabhost Setting Programattically


tabHost.setOnTabChangedListener(new OnTabChangeListener() {
@Override
public void onTabChanged(String arg0) {

// Log.i("***Selected Tab", "Im currently in tab with index::" +
// tabHost.getCurrentTab());
selTabPos = tabHost.getCurrentTab();
for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) {
if (i == selTabPos) {
tabHost.getTabWidget()
.getChildAt(i)
.setBackgroundColor(Color.parseColor("#4a92ce"));
} else {
tabHost.getTabWidget()
.getChildAt(i)
.setBackgroundColor(Color.parseColor("#253040"));
}


}
}
});

for (int i = 0; i < tabHost.getTabWidget().getTabCount(); i++) {
if (i == selTabPos) {
tabHost.getTabWidget().getChildAt(i)
.setBackgroundColor(Color.parseColor("#4a92ce"));
} else {
tabHost.getTabWidget().getChildAt(i)
.setBackgroundColor(Color.parseColor("#253040"));
}

tabHost.getTabWidget().getChildAt(i).getLayoutParams().height = height / 15;
}

No comments: