IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Scroller un LinearLayout


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 62
    Par défaut Scroller un LinearLayout
    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 :

    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;
    	}
    je ne trouve vraiment pas comment faire

  2. #2
    Expert confirmé

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Billets dans le blog
    3
    Par défaut
    Un LinearLayout ne fait pas de scrolling.
    Pour avoir du scrolling, il faut placer ce layout à l'intérieur d'un ScrollView..

  3. #3
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    62
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Meurthe et Moselle (Lorraine)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Décembre 2011
    Messages : 62
    Par défaut
    c'est ce que j'ai fait entre temps :

    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
    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
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
     
    ScrollView myview = new ScrollView(this);
     
    		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());
     
    		final EditText nom = new EditText(this);
    		nom.setText("Votre nom");
     
    		final 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 : ");
     
    		final 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 : ");
     
    		final 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 : ");
     
    		final RatingBar contenu = new RatingBar(this);
    		contenu.setContentDescription("Note le contenu ");
     
    		noteCompetence.addView(titleNoteContenu);
    		noteCompetence.addView(contenu);
    		/***************************************************************************************************/
     
    		/******* NOTE Exemple *************************************************************************/
    		LinearLayout noteExemple = new LinearLayout(this);
    		noteExemple.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    		noteExemple.setOrientation(LinearLayout.VERTICAL);
    		noteExemple.setGravity(Gravity.CENTER);
     
    		TextView titleNoteExemple = new TextView(this);
    		titleNoteExemple.setText("Noter les exemples : ");
     
    		final RatingBar exemple = new RatingBar(this);
    		exemple.setContentDescription("Note le contenu ");
     
    		noteExemple.addView(titleNoteExemple);
    		noteExemple.addView(exemple);
    		/***************************************************************************************************/
     
    		/******* NOTE Reponse *************************************************************************/
    		LinearLayout noteReponse = new LinearLayout(this);
    		noteReponse.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    		noteReponse.setOrientation(LinearLayout.VERTICAL);
    		noteReponse.setGravity(Gravity.CENTER);
     
    		TextView titleNoteReponse = new TextView(this);
    		titleNoteExemple.setText("Noter les réponses : ");
     
    		final RatingBar reponse = new RatingBar(this);
     
     
    		noteExemple.addView(titleNoteReponse);
    		noteExemple.addView(reponse);
    		/***************************************************************************************************/
     
    		/******* NOTE Slide *************************************************************************/
    		LinearLayout noteSlide = new LinearLayout(this);
    		noteSlide.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    		noteSlide.setOrientation(LinearLayout.VERTICAL);
    		noteSlide.setGravity(Gravity.CENTER);
     
    		TextView titleNoteSlide = new TextView(this);
    		titleNoteExemple.setText("Noter les slides : ");
     
    		final RatingBar slide = new RatingBar(this);
     
     
    		noteExemple.addView(titleNoteSlide);
    		noteExemple.addView(slide);
    		/***************************************************************************************************/
     
    		layout.setScrollbarFadingEnabled(true);
     
    		layout.addView(title);
    		layout.addView(nom);
    		layout.addView(commentaire);
    		layout.addView(noteCompetence);
    		layout.addView(noteConnaissance);
    		layout.addView(noteExemple);
    		layout.addView(noteReponse);
    		layout.addView(noteSlide);
     
    		myview.addView(layout);
    merci pour la confirmation

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. comment faire scroller une MSFlexGrid
    Par sergio_bzh dans le forum VB 6 et antérieur
    Réponses: 4
    Dernier message: 15/11/2005, 11h19
  2. Peut-on scroller lorsqu'on fait un Drag&Drop?
    Par jcs2 dans le forum Langage
    Réponses: 2
    Dernier message: 09/09/2005, 22h17
  3. Faire scroller un texte (générique)
    Par freud dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 21/08/2005, 12h15
  4. comment scroller dans un div avec l'evenement onmousemove.
    Par julien.v dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 13/06/2005, 16h08
  5. [VCL] Scroller un contrôle par code
    Par sbeu dans le forum Composants VCL
    Réponses: 3
    Dernier message: 31/03/2004, 10h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo