bonsoir
je dois ajouter des items a un spinner android a partir une base de donnée mysql , est ce qu'il es possible ? si oui s'il vous plait comment je peut faire ca :?
merci d'avance :D
Version imprimable
bonsoir
je dois ajouter des items a un spinner android a partir une base de donnée mysql , est ce qu'il es possible ? si oui s'il vous plait comment je peut faire ca :?
merci d'avance :D
Bonjour,
Oui c'est possibleCitation:
est ce qu'il es possible ?
Il y a plusieurs manières de le faire. Tu peux créer un service web qui se chargera de te renvoyer les données provenant de ta base de données, soit tu couples json et android en utilisant un script php (c'est à dire, un fichier php simple qui va interroger la base de données et récupérer le résultat pour enfin le renvoyer sous format json. Côté Android tu vas appeler ce fichier et récupérer les données qui viennent avec, le décoder puis les afficher dans ton spinner).Citation:
comment je peut faire ca
Christian,
merci pour votre réponse :D
j'essai de faire ca avec cet exemple http://www.techques.com/question/1-1...-to-each-other
et j'ai un message d'erreur "adresse ip invalid" (je test le answer 1 )
et voici mon logcat
Code:
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 693-693/com.example.ghazi.spinner D/gralloc_goldfish﹕ Emulator without GPU emulation detected. 05-14 15:24:20.815 693-693/com.example.ghazi.spinner E/Fail 1﹕ android.os.NetworkOnMainThreadException 05-14 15:24:20.965 693-693/com.example.ghazi.spinner E/Fail 2﹕ java.lang.NullPointerException 05-14 15:24:20.975 693-693/com.example.ghazi.spinner E/Fail 3﹕ java.lang.NullPointerException 05-14 15:26:37.976 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:38.435 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:38.720 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:39.495 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:40.066 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:40.353 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:40.465 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:40.896 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:41.095 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:41.555 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:41.715 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:42.036 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:42.132 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:42.525 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:42.715 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:43.177 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:43.326 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:43.916 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:44.106 735-735/com.example.ghazi.spinner D/gralloc_goldfish﹕ Emulator without GPU emulation detected. 05-14 15:26:44.286 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:26:44.615 735-740/com.example.ghazi.spinner I/dalvikvm﹕ threadid=3: reacting to signal 3 05-14 15:26:44.845 735-740/com.example.ghazi.spinner I/dalvikvm﹕ Wrote stack traces to '/data/anr/traces.txt' 05-14 15:32:01.635 735-735/com.example.ghazi.spinner E/Fail 1﹕ android.os.NetworkOnMainThreadException 05-14 15:32:02.075 735-735/com.example.ghazi.spinner E/Fail 2﹕ java.lang.NullPointerException 05-14 15:32:02.085 735-735/com.example.ghazi.spinner E/Fail 3﹕ java.lang.NullPointerException
" NetworkOnMainThreadException" arrive quand tu fais des appels réseaux dans le thread qui gère l'interface graphique. Utilise un thread séparé, soit mieux asyncTask quand tu fais des appels réseaux.
s'il vous plait s'il y a un tuto , je suis novice au android :/