voila depuis hier j'essaye différente solution mais sans résultat je suis bloquer sur la conception d'un tab host
je ne trouve pas mon erreur
eclipse me dit que tout est bon mais quand je lance une simulation j'ai un Fc
dans mon main.java j'ai
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 package com.formation.tabhost; import android.app.Activity; import android.os.Bundle; import android.widget.TabHost; import android.widget.TabHost.TabSpec; public class ActiviteTab extends Activity { private TabHost monTabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); monTabHost =(TabHost) findViewById(R.id.TabHost01); monTabHost.setup(); TabSpec spec = monTabHost.newTabSpec("onglet_1"); spec.setIndicator("Onglet 1",getResources().getDrawable(R.drawable.icon)); monTabHost.addTab(spec); monTabHost.addTab(monTabHost.newTabSpec("onglet_2").setIndicator( "Onglet 2").setContent(R.id.Onglet2)); monTabHost.addTab(monTabHost.newTabSpec("onglet_3").setIndicator( "Onglet 3").setContent(R.id.Onglet3)); monTabHost.setOnTabChangedListener( new TabHost.OnTabChangeListener (){ public void onTabChanged(String tabId){ } } ); } }
dans mon layout/main.xml
au final j'essaye de faire ceci
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@+id/TabHost01" 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"> </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="vertical" android:id="@+id/Onglet1"> <TextView android:text="Ceci est un texte dans longlet 1" android:id="@+id/TextViewOnglet1" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/Onglet2"> <TextView android:text="Ceci est un texte dans longlet 2" android:id="@+id/TextViewOnglet2" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"> </ImageView> </LinearLayout> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/Onglet3"> <TextView android:text="Ceci est un texte dans longlet 3" android:id="@+id/TextViewOnglet3" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost> </LinearLayout> [/quote] Mon layout/tab <div class="bbcode_container"> <div class="bbcode_quote"> <div class="quote_container"> <div class="bbcode_quote_container"></div> <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@+id/monTextView" android:text="Coucou" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical|center_horizontal"/> </LinearLayout> </div> </div> </div>et mon android manifest [quote]<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.formation.tabhost" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="15" /> <activity android:name="ActiviteTab"></activity> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".ActiviteTab" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
Partager