Bonjour,
J'ai un nouveau problème... je souahite passer les données récupérées dans mon thread vers ma vue principale
je demarre mon appli :
Dans mon thread :
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 public class DatiActivity extends Activity implements Runnable{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN); WindowManager.LayoutParams attrs = getWindow().getAttributes(); attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; getWindow().setAttributes(attrs); Thread currentThread = new Thread(this); currentThread.start(); }
Je n'ai aucun probleme pour afficher le résultat dans un toast .... mais je souhaite pouvoir afficher tout cela dans ma vue principale ( TextView -> "@+id/apNom" et "@+id/apType")
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 public void run() { ........................... ipAddress = info.getIpAddress(); ip = String.format("%d.%d.%d.%d", // --- transforme l'@IP au format reconnu (ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff)); URL_DATE_UPDATE = "http://192.168.0.115/liste_appel/Fichiers_appel/".concat(ip); //chaque tablette récupère le fichier ayant comme nom, sa propre adresse IP String testText = getHttpGet(URL_DATE_UPDATE); String[] expression = testText.split("\\."); ............................................... }
Je me doute que c'est simple, mais je m'embrouille dans les tutos qui présentent tous des exemples avec des boutons comme déclancheur, alors que moi cela doit être mis a jour toute les secondes si le fichier existe ....
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 <?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" android:background="#88ccff" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_gravity="center" android:layout_weight="1" android:text="@string/hello" android:textColor="#0000ff" android:textSize="35dp" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#88ccff" android:gravity="center" android:orientation="vertical" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#88ccff" android:gravity="center" android:orientation="horizontal" > <TextView android:id="@+id/textNom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:text="@string/nom" android:textColor="#0000ff" android:textSize="25dp" /> <TextView android:id="@+id/apNom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:textColor="#0000ff" android:textSize="25dp" /> </LinearLayout> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#88ccff" android:gravity="center" android:orientation="horizontal" > <TextView android:id="@+id/textType" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:text="@string/type" android:textColor="#0000ff" android:textSize="25dp" /> <TextView android:id="@+id/apType" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="1" android:textColor="#0000ff" android:textSize="25dp" /> </LinearLayout> </LinearLayout> </LinearLayout>
Merci par avance... je vais refroidir un peu mes pauvres neuronnes de débutant !!
Partager