Fks Posted June 29, 2011 Share Posted June 29, 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 Link to comment Share on other sites More sharing options...
nahzhir Posted June 29, 2011 Share Posted June 29, 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.