Hi everyone.
I'm having problem with creating AlertDialog. I would like that
AlertDialog appears when i click on one button, so i put all code for
creating dialog in that button listener...the same code works outside
that listener but inside listener doesn't work...it doesn't call any
errors but when i start emulator written is something about this:
Aplication has terminater unexpected"....

This is my code for that:

btsenddata.setOnClickListener(new Button.OnClickListener() {


                public void onClick (View v){

                                AlertDialog.Builder alt_bld = new
AlertDialog.Builder(getApplicationContext() );
                                alt_bld.setMessage("Do you want to close this 
window ?")
                                .setCancelable(false)
                                .setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int 
id) {
                                // Action for 'Yes' Button
                                }
                                })
                                .setNegativeButton("No", new 
DialogInterface.OnClickListener()
{
                                public void onClick(DialogInterface dialog, int 
id) {
                                //  Action for 'NO' Button
                                dialog.cancel();
                                }
                                });
                                AlertDialog alert = alt_bld.create();
                                // Title for AlertDialog
                                alert.setTitle("Title");
                                // Icon for AlertDialog
                                alert.setIcon(R.drawable.icon);
                                alert.show();
                }});


.... i've heard that method getApplicationContext() is creating some
problems but i've tried replace it with activity.this and it doesn't
work anyway...

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to