获得Android的快速输入字符串 [英] get a fast String input in android
本文介绍了获得Android的快速输入字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一个快速的方式来获得针对Android用户的输入字符串。
例如Java中的code:
JOptionPane.showInputDialog(NULL,输入你输入);
获取来自用户的输入。我在寻找的Android等这个事情。
解决方案
AlertDialog.Builder警报=新AlertDialog.Builder(本);alert.setTitle(标题);
alert.setMessage(信息);//设置一个EditText视图来获取用户输入
最终的EditText输入=新的EditText(本);
alert.setView(输入);alert.setPositiveButton(OK,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){
字符串值= input.getText();
//做一些与价值!
}
});alert.setNegativeButton(取消,新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){
// 取消。
}
});alert.show();
I'm looking for a fast way to get an input String from the user in Android. For example in java the code:
JOptionPane.showInputDialog(null, "enter your input");
gets the input from the user. I'm looking such this thing in Android.
解决方案
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Title");
alert.setMessage("Message");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText();
// Do something with value!
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
这篇关于获得Android的快速输入字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文