Try,

TabWidget tw = getTabWidget();

for (int i = 0; i < tw.getChildCount(); i++) {
            View v = tw.getChildAt(i);
            v.setBackgroundDrawable(getResources().getDrawable
(R.drawable.tabindicator));
          }

On Jul 28, 10:01 am, Ludwig Heinz <[email protected]> wrote:
> Hi guys,
>
> a simple question: how to change the TabBackground in the different
> states (not the icon!) ?
>
> my files:
>
> tabindicator.xml
>
> <selector xmlns:android="http://schemas.android.com/apk/res/android";>
> <item android:state_focused="false"
>       android:state_selected="false"
>       android:state_pressed="false"
>       android:drawable="@drawable/tab_focus"/>
> <item android:state_focused="false"
>       android:state_selected="true"
>       android:state_pressed="false"
>       android:drawable="@drawable/tab_focus"/>
> <item android:state_focused="true"
>       android:state_selected="false"
>       android:state_pressed="false"
>       android:drawable="@drawable/tab_focus"/>
> <item android:state_focused="true"
>       android:state_selected="true"
>       android:state_pressed="false"
>       android:drawable="@drawable/tab_focus"/>
> <item android:state_pressed="true"
>       android:drawable="@drawable/tab_press"/>
> </selector>
>
> where should i call the xml file above???
>
> i tried it in the TabWidget as src, but it doesn't work:
>
> <TabHost xmlns:android="http://schemas.android.com/apk/res/android";
>     android:id="@android:id/tabhost"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent">
>     <LinearLayout
>         android:orientation="vertical"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent">
>         <TabWidget
>             android:id="@android:id/tabs"
>             android:layout_width="fill_parent"
>             android:layout_height="wrap_content"
>             android:src="@layout/tabindicator"> // look here
>         </TabWidget>
>         <FrameLayout
>             android:id="@android:id/tabcontent"
>             android:layout_width="fill_parent"
>             android:layout_height="fill_parent">
>         </FrameLayout>
>     </LinearLayout>
> </TabHost>
>
> So i tried to use a own theme:
>
> <?xml version="1.0" encoding="utf-8"?>
> <resources>
>         <style name="tab" parent="android:Theme.Light">
>                 <item name="android:tabWidgetStyle">@style/tabindicatorstyle</
> item>
>         </style>
>         <style name="tabindicatorstyle" parent="@android:style/
> Widget.TabWidget">
>                 <item name="android:???">@layout/tabindicator</item>
>         </style>
> </resources>
>
> but i don't know, which resource i should use instead of "???"...
>
> can anyone help me?
>
> many thanks in advancde!
>
> king regards!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to