Hello all,

I've been trying to access the values of the EditTexts in the alert
dialog text entry API demo. I've added two lines to the code in the
onClick method for the

case DIALOG_TEXT_ENTRY: // This example shows how to add a custom
layout to an AlertDialog LayoutInflater factory = LayoutInflater.from
(this);
final View textEntryView = factory.inflate
(R.layout.alert_dialog_text_entry, null);
return new AlertDialog.Builder(AlertDialogSamples.this) .
setIcon(R.drawable.alert_dialog_icon) .setTitle
(R.string.alert_dialog_text_entry) .
setView(textEntryView) .setPositiveButton(R.string.alert_dialog_ok,
newDialogInterface.OnClickListener()
 {
 public void onClick(DialogInterface dialog, int whichButton) {

/* User clicked OK so do some stuff */
 EditText userNameEt= (EditText) findViewById(R.id.username_edit);
 String userName= userNameEt.getText().toString();

} }) .setNegativeButton(R.string.alert_dialog_cancel, new
DialogInterface.OnClickListener() { public void onClick
(DialogInterface dialog, int whichButton) {

/* User clicked cancel so do some stuff */ } })
 .create();
}

It runs fine until i press the "Ok" button. I then get an "application
closed unexpectadly" error. What is the correct way to access the
values here?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to