Fks Posté(e) 29 juin 2011 Posté(e) 29 juin 2011 Bonjour, Pour une application, je récupère le texte d'un textview et je veux le comparer à 0. Je fais donc ça : TextView TexteEcran = (TextView)findViewById(R.id.TexteEcran); if (TexteEcran.getText()=="0") { TexteEcran.setText(Touche); } else { TexteEcran.setText(TexteEcran.getText() + Touche); } Dans le déboggueur il m'indique que TexteEcran.getText() est égal à 0 mais le if ne marche jamais. Qqn à une piste. Frk
nahzhir Posté(e) 29 juin 2011 Posté(e) 29 juin 2011 essai avec ça : TextView texteEcran = (TextView)findViewById(R.id.TexteEcran); if (texteEcran.getText().toString().equals("0")) { texteEcran.setText(Touche); } else { texteEcran.setText(texteEcran.getText() + Touche); } Pour la petite histoire quand tu fais if (TexteEcran.getText()=="0"), tu compares deux instances donc elle sont forcement différentes
Recommended Posts
Archivé
Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.