继承我的代码:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("What's Your name?");
alert.setMessage("Seems like you're new here! What's your name?");
// 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) {
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
这将打开一个带有确定和取消按钮的编辑文本
当你点击确定时我该怎么做才会将TextView的文本更改为框内的内容
答案 0 :(得分:1)
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String newText = input.getText().toString();
textView.setText(newText);
}
});