Reputation: 28379
I just realized that I don't see a way to collect a string from the user in a simple, pre-packaged Dialog prompt. Am I overlooking something or do I really need to write a custom Dialog to perform this function?
Upvotes: 0
Views: 106
Reputation: 6712
Basically I would use an AlertDialog and create a new EditText. Hand it to the Dialog with .setView and handle the text in the onClick-Events.
final EditText prompt = new EditText(this);
AlertDialog.Builder builder = new Builder(this);
builder.setTitle("My fancy title");
builder.setView(prompt);
builder.setPositiveButton("Ok", new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String myText = prompt.getText().toString();
}
});
AlertDialog promptDialog = builder.create();
promptDialog.show();
Upvotes: 2
Reputation: 7041
check this link
http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application
the idea is to use dialog.setContentView(), and make ur own layout there
Upvotes: 3