Bonjour,
je suis en train de développer une application j2me sur mobile avec eclipse 3.4.0.
j'ai un problème de passage à une alerte à partir d'un formulaire appelé à partir d'un midlet.En effet,l'alerte sollicitée suite à l'appel du bouton 'valider' du Form ne s'affiche pas .
Pouvez vous m'aider.
Voici le code:
%%% MIDlet %%%
%%% Form %%%
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 package Test; import javax.microedition.lcdui.Choice; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; import javax.microedition.midlet.*; public class Tache1 extends MIDlet implements CommandListener { private Display display; private Form form; private ChoiceGroup choiceGroup; Command cmd; private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1); public Tache1() { display = Display.getDisplay(this); form = new Form("Operation désirée"); choiceGroup = new ChoiceGroup("", Choice.EXCLUSIVE); choiceGroup.append("mise à jour",null); choiceGroup.append("recevoir statistiques", null); choiceGroup.setSelectedFlags(new boolean[] { false, false }); form.append(choiceGroup); this.cmd = new Command("Suivant", Command.SCREEN, 0); form.addCommand(cmd); form.addCommand(CMD_EXIT); form.setCommandListener(this); } public void startApp() { display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable d) { if (c == this.cmd){ new update1(this); } } }
Merci beaucoup
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 package Test; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import javax.microedition.lcdui.ChoiceGroup; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Display; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Form; public class Update1 extends Form implements CommandListener{ Tache1 t; private Display display; private Form form; private ChoiceGroup choiceGroup; Command cmd; private final static Command CMD_EXIT = new Command("Exit", Command.EXIT, 1); public Update1(Tache1 t) { super ("Mise à jour"); this.t=t; form=new Form("Mise à jour"); Display.getDisplay(t).setCurrent(this.form); choiceGroup = new ChoiceGroup("", ChoiceGroup.EXCLUSIVE); choiceGroup.append("formater", null); choiceGroup.append("modifier", null); choiceGroup.append("charger", null); choiceGroup.append("ajouter", null); choiceGroup.append("supprimer", null); choiceGroup.setSelectedFlags(new boolean[] { false, false, false, false,false }); this.form.append(choiceGroup); this.cmd = new Command("valider", Command.SCREEN, 0); this.form.addCommand(this.cmd); this.form.addCommand(CMD_EXIT); this.form.setCommandListener(this); } public void commandAction(Command c, Displayable d) { if (c == this.cmd) { String text = " connexion NFC..."; Alert a = new Alert("Please , wait", text, null, AlertType.INFO); this.display.setCurrent(a); } } }
Meilleures Salutations
Partager