我在 android 中有一个 EditText,我希望用户在其中输入文本并检查条件“BYE”
代码示例:
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
}
如何让用户输入文本?UI 应该等待输入文本(类似于我们在 Java 应用程序中有 InputStreamReader)。
最佳答案
非常简单:-
EditText text = (EditText)findViewById(R.id.EditText01);
String str = text.getText().toString();
现在在 str 中你将得到在 EditText 中输入的字符串
关于android - 如何在android中获取用户的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3766900/