AlertDialog with EditText Android:

AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);

alert.setTitle("Title");

alert.setMessage("Message");

// Set an EditText view to get user input
EditText input = new EditText(MainActivity.this);

alert.setView(input);

alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

  String value = input.getText().toString();

  Log.e("edit", value+ " va ");
  // Do something with value!
  
}
});

alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
    // Canceled.
  }
});
alert.show();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s