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, new
DialogInterface.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?

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to