Hello all,
I've been playing around with the dialogs and have been trying to get
the values of the username and password EditTexts in the text entry
dialog API demo. I added the two lines of code to try to get the value
in the onClick method:
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, new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
whichButton) {
EditText userNameEditText= (EditText)
findViewById(R.id.username_edit);
String userName=
userNameEditText.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();
}
return null;
It runs ok until i push the "ok" button. I then get an "application
has stopped unexpectedly" error.
What is the right way to access the values?
Cheers
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---