Skip to content

Instantly share code, notes, and snippets.

@sendtomitesh
Created June 24, 2014 11:17
Show Gist options
  • Select an option

  • Save sendtomitesh/6117162d7eda8a4d6cb4 to your computer and use it in GitHub Desktop.

Select an option

Save sendtomitesh/6117162d7eda8a4d6cb4 to your computer and use it in GitHub Desktop.
Simple text entery dialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Title");
// Set up the input
final EditText input = new EditText(this);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
builder.setView(input);
// Set up the buttons
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
m_Text = input.getText().toString();
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment