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
| package com.android.androizz;
import android.content.Context;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.view.Gravity;
import android.view.View;
public class FormQuest2 extends ScrollView{
private Button boutonValider, boutonAnnuler, boutonTerminer;
private EditText et1, et2, et3, et4, et5;
private Object parent;
private TextView tv1, tv2, tv3;
private Questionnaire questionnaire;
public FormQuest2(Context context, Questionnaire q){
super(context);
parent=context;
questionnaire = q;
LinearLayout l=new LinearLayout(context);
l.setOrientation(1);
tv1 = new TextView(context);
tv1.setText("Question :");
l.addView(tv1);
et1 = new EditText(context);
et1.setText("");
et1.setSingleLine();
l.addView(et1);
tv2 = new TextView(context);
tv2.setText("Bonne réponse");
l.addView(tv2);
et2 = new EditText(context);
et2.setText("");
et2.setSingleLine();
l.addView(et2);
tv3 = new TextView(context);
tv3.setText("Réponses possible");
l.addView(tv3);
et3 = new EditText(context);
et3.setText("");
et3.setSingleLine();
l.addView(et3);
et4 = new EditText(context);
et4.setText("");
et4.setSingleLine();
l.addView(et4);
et5 = new EditText(context);
et5.setText("");
et5.setSingleLine();
l.addView(et5);
this.boutonAnnuler = new Button(context);
this.boutonAnnuler.setText("Annuler");
l.addView(this.boutonAnnuler);
this.boutonValider = new Button(context);
this.boutonValider.setText("Continuer");
l.addView(this.boutonValider);
this.boutonTerminer = new Button(context);
this.boutonTerminer.setText("Valider");
l.addView(this.boutonTerminer);
addView(l);
boutonAnnuler.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
((Androizz)parent).annulerFormulaire();
}
});
boutonValider.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
/*traitement des EditText*/
scrollTo(0,0); // Aucun effet ?
((Androizz)parent).formulaire2(questionnaire); // le questionnaire tourne en boucle
// tant qu'on ne le termine pas pour pouvoir
// entrer une série de question.
}
});
boutonTerminer.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
((Androizz)parent).Terminer(questionnaire); //Plante quand la taille du formulaire est trop grande pour l'écran
// et que ca scroll.
}
});
}
} |
Partager