M-Samus Posted July 7, 2010 Share Posted July 7, 2010 Bonjour a tous ! Je me suis récemment mis a dev sous android et j'ai pas encore compris l'utilisation du EditText et du getTxt() pourriez-vous m'aider ? Clairement j'ai un layout avec un EditText et dans mon .java j'ai une variable String text = ""; Comment faut-il faire pour recuperer cette chaine de caracteres taper par l'utilisateur ? Merci d'avance pour la réponse cordialement ! Link to comment Share on other sites More sharing options...
Rataah Posted July 8, 2010 Share Posted July 8, 2010 EditText myEditText = (EditText) findViewById(R.id.id_du_edittext); La fonction "findViewById" te permet de retrouver un objet de type View (dont EditText en fais parti) en lui passant par exemple son ID. Bien sur, ton EditText doit avoir un ID : android:id="@+id/le_nom_id" par exemple. text = myEditText .getText().toString(); ensuite tu appel la fonction getText() de ton EditText qui te retourne un objet "Editable" et tu appel dessus la fonction "toString()" pour avoir un String ! Voila. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.