my tab bar icon wont show up
TabHost tabHost = getTabHost();
TabSpec barcodeInsertSpec = tabHost.newTabSpec("Barcode Insert");
barcodeInsertSpec.setIndicator("Barcode Insert", getResources().getDrawable(R.drawable.home2));
barcodeInsertSpec.setContent(new Intent(getBaseContext(), BarcodeInsertActivity.class));
tabHost.addTab(barcodeInsertSpec);
drawable/home2.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When not selected, use that-->
<item android:drawable="@drawable/home22" />
</selector>
and put picture in three folders in different sizes (48x48, 32x32, 24x24) drawable-hdpi , drawable-ldpi, ... as .png
like drawable-hdpi/home22.png
Try This.
*You can also use a custom item selector in place of drawable to make a focused and pressed effects. Cheers!
I had the same problem using Xamarin.
This was a hack solution that shows the icon but NOT the text (looks like an android defect):This solution shows both, but it hosed my app-wide styles, which indicates to me that I could probably set up a style override:
EDIT 10 OCT 2013 - I got it to work in c#! It should be straightforward to do the same in java
I was able to get tabs to show up with icons with code and a custom style. See below
tab_indicator_holo.xml:
My Activity OnCreate:
This code is work for me :)
try this code
Hi Use the drawable selector file like this.