Answer the question
In order to leave comments, you need to log in
Changing icons in tabs (Android)?
The question is this: I want to change the tab icon (Android TabHost), when I click on the tab or when I hover focus.
I wrote selectors, googled, the solution is obvious through selectors, I wrote, added icons, added drawable, but nothing happens, the icons do not change. Who faced similar?
Answer the question
In order to leave comments, you need to log in
Believe it or not, only these and a couple of dozen more tutorials did not help. Did everything as there and does not work. Unfortunately, the code still works...
Here are a couple of tutorials on this topic:
developer.android.com/resources/tutorials/views/hello-tabwidget.html
It says that you can use several drawables for a tab, for different states (state-list drawable).
android_menu_button.xml:
MainActivity.java:
Resources res = getResources(); tabRecipeTabSpec.setIndicator("",res.getDrawable(R.drawable.android_menu_button) ).setContent(new Intent(this,RecipeTab.class));
recipe_tab_menu_.png, recipe_tab_menu.png files are in drawable-hdpi. What could be the problem?
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/recipe_tab_menu_"
android:state_selected="true"
android:state_pressed="false"
android:color="#ffffff"/>
<item android:drawable="@drawable/recipe_tab_menu" />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question