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

Composants graphiques Android Discussion :

ListView image problème


Sujet :

Composants graphiques Android

  1. #1
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut ListView image problème
    Salut à tous,

    Voilà, j'ai une Listview de par exemple 50 items avec un Textview et une image view par ligne. Les imageView sont invisible par défaut au chargement de la listview dans mon adapter. Ce que je souhaite faire c'est lorsque je clique une ligne de ma listview imageview devienne visible. Elle devient visible à la ligne à la bonne ligne ou j'ai cliqué mais lorsque je scroll elle est visible sur des items plus bas hors écran... Alors que moi je veut qu'elle soit visible juste sur la première ligne de ma listview et non sur la 11 ém ligne 21 ém ligne etc..

    Voilà si vous avez déjà eu le soucis et que vous avez une solution je suis preneur

    Cordialement,

  2. #2
    Membre averti
    Homme Profil pro
    Ingénieur Informatique et Développeur Android
    Inscrit en
    Janvier 2010
    Messages
    384
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur Informatique et Développeur Android

    Informations forums :
    Inscription : Janvier 2010
    Messages : 384
    Points : 321
    Points
    321
    Par défaut
    Bonjour,
    je n'ai pas compris ton besoin.
    Mais lorsque tu veux un view sera visible ou invisible tu peux utiliser exemple

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    imageview1.setVisibility
    (View.Visible ou Invisible)

    merci

  3. #3
    Rédacteur
    Avatar de MrDuChnok
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2002
    Messages
    2 112
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Juin 2002
    Messages : 2 112
    Points : 4 240
    Points
    4 240
    Par défaut
    Salut,

    Tu peux mettre le code de ta méthode getView de ton adapter ?

    Merci
    Si vous jugez mon post utile dans la résolution de votre problème, n'hésitez pas à utiliser le système de vote afin d'améliorer la qualité du forum

  4. #4
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut
    Merci à vous pour vos réponse.

    J'ai une ListView à qui je lui attribue un adapteur. Sur cette adapteur il y a une ImageView qui est invisible au chargement et ensuite deux TextView. Lorsque je clique sur une ligne je souhaite que mon imageview devienne visible. Cela fonctionne parfaitement si j'ai pas à scroller. Par contre si je doit scrollé là mes ImageView devienne visible à des endroits innatendue.

    Code de mon GetView :
    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
     public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	// textview
                holder.tv_nom_sound = (TextView) convertView.findViewById(R.id.tv_name_record);
                holder.tv_duree_sound = (TextView) convertView.findViewById(R.id.tv_duration_sound);
                holder.tv_heure_sound = (TextView) convertView.findViewById(R.id.tv_heures_sound);
                holder.tv_poid_sound = (TextView) convertView.findViewById(R.id.tv_poids_sound);
     
     
                	// image view
                holder.img_pause_play = (ImageView) convertView.findViewById(R.id.img_pause_play);
     
                	// linear layout
               holder.linearLayout_ligne = (LinearLayout) convertView.findViewById(R.id.LinearLayout_ligne);
     
                holder.linearLayout_ligne.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					    holder.img_pause_play.setVisibility(View.VISIBLE);
     
    				}
    			});
     
               holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					holder.img_pause_play.setVisibility(View.INVISIBLE);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
                convertView.setTag(holder);
            }
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
     
             Log.e("VALEUR DE POSITION : ", String.valueOf(position));
             holder.linearLayout_ligne.setTag(position);
             holder.tv_position_list_view.setText(String.valueOf(position));
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
             holder.tv_duree_sound.setText(((Sound) itemList.get(position)).getDuree());
             holder.tv_heure_sound.setText(((Sound) itemList.get(position)).getHeure());
             holder.tv_poid_sound.setText(((Sound) itemList.get(position)).getPoids());
     
     
            return convertView;
        }

  5. #5
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    757
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 757
    Points : 968
    Points
    968
    Par défaut
    Tout d’abord, il faut que tu déplace tes listeners dans la seconde partie de ton getView.
    Et tu dois à chaque appel de getView définir si l'image doit être visible ou non, car les vues sont recyclées.

    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
     
    public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	//tout le reste du binding uniquement (pas les listeners)
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
             //et à partir d'ici, toutes les modifications (setText etc) ainsi que les listeners
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
     
             //ainsi que les listeners
             holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					              holder.img_pause_play.setVisibility(View.INVISIBLE);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
             //Mais sans oublier de dire si l'image doit être visible ou non :
              holder.img_pause_play.setVisibility(display ? View.INVISIBLE : View.INVISIBLE);
     
    }

  6. #6
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut
    Merci pour ta réponse mais mon soucis est toujours présent.

    code getView :
    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
    public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	// textview
                holder.tv_nom_sound = (TextView) convertView.findViewById(R.id.tv_name_record);
                holder.tv_duree_sound = (TextView) convertView.findViewById(R.id.tv_duration_sound);
                holder.tv_heure_sound = (TextView) convertView.findViewById(R.id.tv_heures_sound);
                holder.tv_poid_sound = (TextView) convertView.findViewById(R.id.tv_poids_sound);
     
     
                	// image view
                holder.img_pause_play = (ImageView) convertView.findViewById(R.id.img_pause_play);
     
                	// linear layout
               holder.linearLayout_ligne = (LinearLayout) convertView.findViewById(R.id.LinearLayout_ligne);
     
     
     
                convertView.setTag(holder);
            }
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
             holder.tv_duree_sound.setText(((Sound) itemList.get(position)).getDuree());
             holder.tv_heure_sound.setText(((Sound) itemList.get(position)).getHeure());
             holder.tv_poid_sound.setText(((Sound) itemList.get(position)).getPoids());
     
             holder.linearLayout_ligne.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					    holder.img_pause_play.setVisibility(View.VISIBLE);
     
    				}
    			});
     
            holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					holder.img_pause_play.setVisibility(View.INVISIBLE);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
            return convertView;
        }
     
    code qui permet de mettre mon Image View visible :
     
    //Fonction appelée au clic sur une ligne
     
    public void item_cliquer(View v) {
    			LinearLayout l = (LinearLayout) v;
    			//on récupère la position à l'aide du tag défini dans la classe MyListAdapter
    			int position = Integer.parseInt(l.getTag().toString());
     
     
    			ImageView img = (ImageView) liste_sound.getChildAt(position).findViewById(R.id.img_pause_play);
    			img.setVisibility(View.VISIBLE);
    }
    Lorsque j'attribue visible sur ma listview ça me parait correct non ?

    Merci en tous cas pour vos réponse.

  7. #7
    Expert éminent

    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
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Citation Envoyé par nico_nico95 Voir le message
    Lorsque j'attribue visible sur ma listview ça me parait correct non ?
    .
    Non

    J'ai répondu à ce sujet dans un autre thread.

    getChildAt() dans une ListView ne *correspond pas* au layout visible numéro X (la ListView peut introduire d'autres views comme les séparateurs), et encore moins à l'item numéro Y (le layout numéro X ne correspond pas à l'item numéro Y).

    Je vais entrer dans plus de détails.... Disons que la ListView peut afficher 3 éléments.
    Ta liste en contient 7....

    A l'initialisation de la ListView (avec l'adapter) voici ce qui va se passer:

    La ListView va appeler l'adapter pour les éléments visible #0, #1 et #2 (appel de getView() avec null comme convertView), et rajouter ces Views dans sa propre liste (par exemple à l'index / getViewAt() 3, 5 et 7, 4 et 6 étant utilisé pour les séparateurs).

    Ensuite, tu scroll vers le bas... les éléments visibles seront #2, #3 et #4....
    La ListView a déjà #2, elle va donc juste la déplacer à l'index 3 de sa liste... par contre elle n'a plus #0 et #1 (recycling), et va appeler getView() sur #3 et #4 en réutilisant les views obtenus pour #0 et #1 => pas de création de view, juste un déplacement dans la liste...
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  8. #8
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut
    Merci pour tes précisions en voyant sous cette angle c'est sur que ça ne peut fonctionner.

    Maintenant je réalise tout mon traitement dans mon GetView de mon adapter est mon problème persiste :/

    code de mon getView :
    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
    public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	// textview
                holder.tv_nom_sound = (TextView) convertView.findViewById(R.id.tv_name_record);
                holder.tv_duree_sound = (TextView) convertView.findViewById(R.id.tv_duration_sound);
                holder.tv_heure_sound = (TextView) convertView.findViewById(R.id.tv_heures_sound);
                holder.tv_poid_sound = (TextView) convertView.findViewById(R.id.tv_poids_sound);
     
     
                	// image view
                holder.img_pause_play = (ImageView) convertView.findViewById(R.id.img_pause_play);
     
                	// linear layout
               holder.linearLayout_ligne = (LinearLayout) convertView.findViewById(R.id.LinearLayout_ligne);
     
     
     
                convertView.setTag(holder);
            }
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
             holder.tv_duree_sound.setText(((Sound) itemList.get(position)).getDuree());
             holder.tv_heure_sound.setText(((Sound) itemList.get(position)).getHeure());
             holder.tv_poid_sound.setText(((Sound) itemList.get(position)).getPoids());
     
             holder.linearLayout_ligne.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					    holder.img_pause_play.setVisibility(View.VISIBLE);
     
    				}
    			});
     
            holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					holder.img_pause_play.setVisibility(View.INVISIBLE);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
            return convertView;
        }
    Si vous avez des idées je suis prenneur merci d'avance
    Il doit bien y'avoir un autre dev qui est eu ce soucis non ?

  9. #9
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    757
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 757
    Points : 968
    Points
    968
    Par défaut
    Je vois que tu n'as pas lu tout mon message....
    Alors je recommence :
    Tu DOIS définir si l'image est visible ou non à CHAQUE fois que getView() est appelée.

    Regarde à la ligne 34

    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
    public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	// textview
                holder.tv_nom_sound = (TextView) convertView.findViewById(R.id.tv_name_record);
                holder.tv_duree_sound = (TextView) convertView.findViewById(R.id.tv_duration_sound);
                holder.tv_heure_sound = (TextView) convertView.findViewById(R.id.tv_heures_sound);
                holder.tv_poid_sound = (TextView) convertView.findViewById(R.id.tv_poids_sound);
     
     
                	// image view
                holder.img_pause_play = (ImageView) convertView.findViewById(R.id.img_pause_play);
     
                	// linear layout
               holder.linearLayout_ligne = (LinearLayout) convertView.findViewById(R.id.LinearLayout_ligne);
     
     
     
                convertView.setTag(holder);
            }
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
             holder.tv_duree_sound.setText(((Sound) itemList.get(position)).getDuree());
             holder.tv_heure_sound.setText(((Sound) itemList.get(position)).getHeure());
             holder.tv_poid_sound.setText(((Sound) itemList.get(position)).getPoids());
             holder.img_pause_play.setVisibility(((Sound) itemList.get(position)).isVisible());
     
             holder.linearLayout_ligne.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					    holder.img_pause_play.setVisibility(View.VISIBLE);
                                                ((Sound) itemList.get(position)).setVisible(true);
    				}
    			});
     
            holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					holder.img_pause_play.setVisibility(View.INVISIBLE);
                                            ((Sound) itemList.get(position)).setVisible(false);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
            return convertView;
        }
    Pour que cela fonctionne correctement, rajoute ce champ dans ta classe Sound :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    private boolean visible;
    Ainsi que ces méthodes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    public void setVisible(boolean b){
        this.visible = b;
    }
    public boolean isVisible(){
        return this.visible;
    }

  10. #10
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut
    Simon MARQUIS ça fonctionne enfin merci d'avoir pris le temps de me déloquer . et merci aux autres également

    Pour les personnes qui auront le problème également voici le code du getView :
    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
    public View getView(final int position, View convertView, ViewGroup parent) {
     
            final ViewHolder holder;
            if(convertView==null)
            {
                holder = new ViewHolder();
                convertView = inflater.inflate(R.layout.adapter_list_sound, null);
     
                	// textview
                holder.tv_nom_sound = (TextView) convertView.findViewById(R.id.tv_name_record);
                holder.tv_duree_sound = (TextView) convertView.findViewById(R.id.tv_duration_sound);
                holder.tv_heure_sound = (TextView) convertView.findViewById(R.id.tv_heures_sound);
                holder.tv_poid_sound = (TextView) convertView.findViewById(R.id.tv_poids_sound);
     
     
                	// image view
                holder.img_pause_play = (ImageView) convertView.findViewById(R.id.img_pause_play);
     
                	// linear layout
               holder.linearLayout_ligne = (LinearLayout) convertView.findViewById(R.id.LinearLayout_ligne);
     
     
     
                convertView.setTag(holder);
            }
            else{
            	holder=(ViewHolder)convertView.getTag();
            }
     
             holder.tv_nom_sound.setText(((Sound) itemList.get(position)).getNom());
             holder.tv_duree_sound.setText(((Sound) itemList.get(position)).getDuree());
             holder.tv_heure_sound.setText(((Sound) itemList.get(position)).getHeure());
             holder.tv_poid_sound.setText(((Sound) itemList.get(position)).getPoids());
             holder.img_pause_play.setVisibility(((Sound) itemList.get(position)).isVisible());
     
             holder.linearLayout_ligne.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					    holder.img_pause_play.setVisibility(View.VISIBLE);
                                                ((Sound) itemList.get(position)).setVisible(true);
    				}
    			});
     
            holder.img_pause_play.setOnClickListener(new OnClickListener() {
     
    				public void onClick(View v) {
    					// TODO Auto-generated method stub
    					holder.img_pause_play.setVisibility(View.INVISIBLE);
                                            ((Sound) itemList.get(position)).setVisible(false);
    					//ListSoundRecord.mp.pause();    
    				}
    			}); 
     
            return convertView;
        }
    Les propriétés qu'il faut ajouter dans la classe qui charge votre adapter :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    private boolean visible;
     
      // 0 ou 4 car lorsque vous appliquez une visibilité un composant lui ne prend un nombre entier et non true ou false 
    public int isVisible(){
    		if(visible){
    			return 0;
    		}else{
    			return 4;
    		}
    }

  11. #11
    Expert éminent

    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
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Alors...juste histoire de programmer propre....la fonction est "isVisible()" et renvoit un boolean, ou la fonction est "getVisibility()" pour se conformer aux views, et renvoit un int, qui n'est pas 0 ou 4 mais View.VISIBLE ou View.INVISIBLE (ou View.GONE)

    Il est toutefois conseillé de séparer la notion de donnée (started/ou pas), donc avec une fonction "isStarted()" dans les données...

    Et faire la traduction dans l'UI:
    imgView.setVisibility(data.isStarted()?View.GONE:View.VISIBLE);
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  12. #12
    Membre éprouvé
    Profil pro
    Inscrit en
    Janvier 2011
    Messages
    757
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2011
    Messages : 757
    Points : 968
    Points
    968
    Par défaut
    Oups, oui j'ai fait une bourde. Je ne me suis pas relu, mais pour moi c'était évident (tellement j'ai écrit ce genre de code)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    holder.img_pause_play.setVisibility(((Sound) itemList.get(position)).isVisible());
    Devient donc (avec la correction)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    holder.img_pause_play.setVisibility(((Sound) itemList.get(position)).isVisible() ? View.VISIBLE : View.GONE);

  13. #13
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Mai 2012
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2012
    Messages : 129
    Points : 144
    Points
    144
    Par défaut
    Merci à vous.

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

Discussions similaires

  1. Réponses: 4
    Dernier message: 09/12/2005, 22h17
  2. bouton image problème IE
    Par poussinphp dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 09/12/2005, 12h24
  3. [image] Problème de suppression des max locaux avec Canny
    Par Rafoo dans le forum Algorithmes et structures de données
    Réponses: 12
    Dernier message: 06/11/2005, 00h22
  4. [Image] Problème d'ouverture de JPEG CMYK
    Par Robiwan59 dans le forum 2D
    Réponses: 2
    Dernier message: 04/10/2005, 17h22
  5. [IMAGE]Problème d'affichage
    Par LoLoLem dans le forum AWT/Swing
    Réponses: 2
    Dernier message: 06/07/2004, 18h41

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