public void showDialogWithEditText() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Server Message");
alert.setMessage("Set Server 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().toString();
}
});
alert.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
// Canceled.
}
});
alert.show();
}
This method will show alertdialog with EditText.You can use "value" variable as required.
Comments
Post a Comment