There are two ways to this :

1.Declare Edite text object globally and create object inside dialog button
Reason:
*final *may be the cause.
2. if(user_input.getText()!=null)
{

user_input.getText().toString();
}
Thanks ,
Sivaprasad.
On Thu, Dec 1, 2011 at 11:18 AM, rajesh <[email protected]> wrote:

> I am create a custom  dialog   for login and password . every thing is
> fine but as application crash when I get the data from EditText i.e.
> String value = user_input.getText().toString();         . below is my
> code and crash point
>
> @Override
>        protected Dialog onCreateDialog(int id)
>        {
>                 switch (id)
>                 {
>
>                   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(this)
>                           //.setIcon(R.drawable.alert_dialog_icon)
>                           //.setTitle(R.string.alert_dialog_text_entry)
>
>                           .setView(textEntryView)
>                           .setPositiveButton("ok", new
> DialogInterface.OnClickListener() { //R.string.alert_dialog_ok
>                               public void onClick(DialogInterface dialog,
> int whichButton) {
>
>                                   final EditText user_input =
> (EditText)findViewById(R.id.username_editText);
>                                   final EditText password_input =
> (EditText)findViewById.id.password_editText);
>
>                                   String value =
> user_input.getText().toString();         // crashes here
>                                                   String value1 =
> password_input.getText().toString();
>                                   System.out.println(value);
>
>                               }
>                           })
>                           .setNegativeButton("cancel", new
> DialogInterface.OnClickListener() { //R.string.alert_dialog_cancel
>                               public void onClick(DialogInterface dialog,
> int whichButton) {
>
>
>
>                               }
>
>                           })
>                           .create();
>
>                            //-------------
>
>
>                 }
>                 return null;
>
>        }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Discuss" 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-discuss?hl=en.
>
>


-- 




















































With Regards,
Sivaprasad.Gangineni,
9441503073.

-- 
You received this message because you are subscribed to the Google Groups 
"Android Discuss" 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-discuss?hl=en.

Reply via email to