Create Custom Action tab bar

250 Views Asked by At

I am trying to create a custom tabbar using this tutorial for android 2.3.3 and above,but the title bar is disabled(Refer the image attached app deployed on Android 2.3.3 ).

enter image description here

Also, how do I customize the titlebar. Please guide me for the same.

1

There are 1 best solutions below

0
On BEST ANSWER

I had a similar problem. I solved it this way. Created new layout for action bar tab's title and initialized first tab like this:

// init first tab indicator
View viewTabMain = getLayoutInflater().inflate(R.layout.your_title_layout, null);
((ImageView) viewTabMain.findViewById(R.id.imgTab)).setImageResource(R.drawable.icon_1);

// add main tab
tabHost.addTab(tabHost.newTabSpec(TAB_MAIN).setIndicator(viewTabMain).setContent(new TabHost.TabContentFactory() {
@Override
public View createTabContent(String s) {
View view = new View(getApplicationContext());
return view;
}
}));

To other tab (or tabs) use the same. I hope this will help you!