Bonjour,
J'ai une TabActivity (tab.java) qui utilise main.xml:
Je n'arrive pas à modifier le TextView "main_nom" depuis une de mes activity.
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 <?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" > <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/main_portrait" android:src="@drawable/cat" android:layout_width="50dip" android:layout_height="50dip" /> <TextView android:id="@+id/main_nom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#000000" android:text="oo" /> </LinearLayout> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <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" android:padding="5dp" /> </LinearLayout> </TabHost> </LinearLayout>
J'ai essayé avec ce code sans succès:
Je n'ai aucune erreure mais le texte ne change pas, coment faire ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 LayoutInflater main_layout = getLayoutInflater(); View v = main_layout.inflate(R.layout.main, null); main_nom = (TextView)v.findViewById(R.id.main_nom); main_nom.setText("montexte");
Merci
Partager