Bonjour à toutes et à tous,
Je possèdes deux onglets pour mon tabHost. J'aimerai modifier le fond de chacun des onglets.
Pour ce faire, je possède deux images. Cependant, je n'arrive pas à définir ces fonds pour chaque onglets.
Pour info, voici mon xml:
Et mon code JAVA:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/group" android:layout_marginBottom="@dimen/marginBottom" android:layout_marginLeft="@dimen/marginLeft" android:layout_marginRight="@dimen/marginRight" android:layout_marginTop="5dp" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" > <FrameLayout android:id="@+id/tabDetail1" android:layout_width="fill_parent" android:layout_height="fill_parent" /> <FrameLayout android:id="@+id/tabDetail2" android:layout_width="fill_parent" android:layout_height="fill_parent" /> </FrameLayout> </LinearLayout> </TabHost>
Merci d'avance pour vos éclaircissement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 private void addNewTab (String indicator, int id) { int totalTabs = tabhost.getTabWidget ().getChildCount (); TabHost.TabSpec tSpec; tSpec = tabhost.newTabSpec (indicator); tSpec.setIndicator (indicator); // Background des onglets if (totalTabs > 0) // TODO : background onglet 2 else // TODO : background onglet 1 tSpec.setContent (id); tabhost.addTab (tSpec); totalTabs++; ((RelativeLayout) tabhost.getTabWidget ().getChildTabViewAt (totalTabs - 1)).removeViewAt (0); ((TextView) ((RelativeLayout) tabhost.getTabWidget ().getChildTabViewAt (totalTabs - 1)).getChildAt (0)).setHeight (30); tabhost.getTabWidget ().getChildAt (totalTabs - 1).getLayoutParams ().height = 70; }
Partager