Bonjour,
Je suis actuellement entrint de chercher comment on peut scroller un linearLayout sous android mais je ne crée pas de xml en faite je passe par du code behind pour créer a la voler une alerteDialog.
cependant les éléments ne sont pas scroller par cette dernière comment faire reconnaître un scroll bar à mon LinearLayout ?
voici le code qui permet de générer en code behind ma vue :
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
79 protected LinearLayout createViewAlertDialog() { LinearLayout layout = new LinearLayout(this); // instancie un linearLayout layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER); TextView title = new TextView(this); title.setText("Noter cette intervention : "+intervention.getMatiere()); EditText nom = new EditText(this); nom.setText("Votre nom"); EditText commentaire = new EditText(this); commentaire.setText("Entré votre commentaire"); /******* NOTE COMPETENCE *************************************************************************/ LinearLayout noteCompetence = new LinearLayout(this); noteCompetence.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); noteCompetence.setOrientation(LinearLayout.VERTICAL); noteCompetence.setGravity(Gravity.CENTER); TextView titleNoteCompetence = new TextView(this); titleNoteCompetence.setText("Noter la compétence : "); RatingBar competence = new RatingBar(this); competence.setContentDescription("Note la compétence de l'intervenant"); noteCompetence.addView(titleNoteCompetence); noteCompetence.addView(competence); /***************************************************************************************************/ /******* NOTE Connaissance *************************************************************************/ LinearLayout noteConnaissance = new LinearLayout(this); noteConnaissance.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); noteConnaissance.setOrientation(LinearLayout.VERTICAL); noteConnaissance.setGravity(Gravity.CENTER); TextView titleNoteConnaissance = new TextView(this); titleNoteConnaissance.setText("Noter la connaissance : "); RatingBar connaissance = new RatingBar(this); connaissance.setContentDescription("Note la connaissance de l'intervenant"); noteCompetence.addView(titleNoteConnaissance); noteCompetence.addView(connaissance); /***************************************************************************************************/ /******* NOTE Contenu *************************************************************************/ LinearLayout noteContenu = new LinearLayout(this); noteContenu.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); noteContenu.setOrientation(LinearLayout.VERTICAL); noteContenu.setGravity(Gravity.CENTER); TextView titleNoteContenu = new TextView(this); titleNoteContenu.setText("Noter le contenu : "); RatingBar contenu = new RatingBar(this); contenu.setContentDescription("Note le contenu "); noteCompetence.addView(titleNoteContenu); noteCompetence.addView(contenu); /***************************************************************************************************/ layout.addView(title); layout.addView(nom); layout.addView(commentaire); layout.addView(noteCompetence); layout.addView(noteConnaissance); return layout; }
voici le code ou j'appelle cette vue :
je ne trouve vraiment pas comment faire
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 public AlertDialog createAlertDialog() { setTitle("Noter cette Intervention : "+intervention.getMatiere()); AlertDialog.Builder builder = new AlertDialog.Builder(this); // Ajoute un bouton pour annuler builder.setCancelable(true) // Ainsi qu'un bouton pour valider .setPositiveButton("OK", new OnClickListener() { // Quand on va valider, on va mettre a jour la Quote et la // reafficher public void onClick(DialogInterface dialog, int which) { } }); builder.setView(this.createViewAlertDialog()); // Generer le "AlertDialog" AlertDialog alert = builder.create(); return alert; }![]()
Partager