Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to take input from user in android

Tags:

android

i have a EditText in android in which i want the user to enter the text and checks for the condition "BYE"

Code sample:

EditText text = (EditText)findViewById(R.id.EditText01);
String abc= text .getText().toString(); 

while( !(abc).equals("bye")){

   abc = text.getText().toString();//user should enter the text from keyboard and the while loop should go and chech the condition.but not able to enter the text

   //do some operation with abc

 }

How can i make user to enter the text??The UI should wait for the text to be entered(something like we have InputStreamReader in java applications).

like image 706
SPB Avatar asked Sep 22 '10 06:09

SPB


1 Answers

Very Simple:-

EditText text = (EditText)findViewById(R.id.EditText01); 
String str = text.getText().toString(); 

now in str u will get string which is entered in EditText

like image 171
Deepak Kumar 'SORTED' Avatar answered Nov 15 '22 00:11

Deepak Kumar 'SORTED'