我有一个像这样的警报对话框:
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
EditText input = new EditText(this);
input.setText(sp.getString("NAME_0",""),TextView.BufferType.EDITABLE);
alertDialogBuilder.setView(input);
String name = input.getText().toString();
alertDialogBuilder.setCancelable(false);
alertDialogBuilder.setTitle("Enter your name"); //Set the title of the box
//alertDialogBuilder.setMessage(""); //Set the message for the box
alertDialogBuilder.setPositiveButton("Start", new DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog, int id){
dialog.cancel(); //when they click dismiss we will dismiss the box
}
});
AlertDialog alertDialog =alertDialogBuilder.create(); //create the box
alertDialog.show(); //actually show the box
问题是“名称”似乎总是空的。是否有其他方法可以从警报对话框内的编辑文本中获取文本?