I am having a problem using AlertDialog for input text.

Code follows ... everything appears on screen as it should until I click OK
- then I get a force close.

I get a null error on line where Editable e = et.getText();.

Second set of eyes and a sturdy brain appreciated...



    private void enter_search(){

        LayoutInflater factory = LayoutInflater.from(this);
        final View textEntryView = factory.inflate(R.layout.search_dialog,
null);

        new AlertDialog.Builder(Peeps.this)

             //.setIcon(R.drawable.alert_dialog_icon)
            .setTitle(R.string.search_dialog_text_entry)
            .setView(textEntryView)
            .setPositiveButton(R.string.search_dialog_ok, new
DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int whichButton)
{

                    EditText et =
(EditText)findViewById(R.id.search_edit);   // !!! apparently I am doing
this wrong!
                    Editable e =
et.getText();                                                   // <<< this
is where the error occurs
                    Log.d(TAG, "search test is " + e.toString());

                }
            })

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

                    /* User clicked cancel so do some stuff */
                }
            })

            .show();

    }

    protected void do_search(String search_text){

        // search here

    }

--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to