Problem with AlertDialog.Builder

by Ivan Longin » Tue, 23 Feb 2010 12:14:09 GMT


Sponsored Links
 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...

--



Problem with AlertDialog.Builder

by TreKing » Tue, 23 Feb 2010 23:37:41 GMT


 



What do you mean it doesn't work anyway? What happens when you use the
activity (what you should be doing)?

-------------------------------------------------------------------------------------------------
TreKing - Chicago transit tracking app for Android-powered devices
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. Debug Appwidget using Eclipse/ADT

Hi all,

I have to debug my widget using Eclipse.
I set a breakpoint in my code, but I don't see the message (displayed
normally with a standard Activity) waiting for de{*filter*}...
And the debug mode is never called...

Do you have an idea? A problem with my configuration?

Thanks for your reply.

Regards
--~--~---------~--~----~------------~-------~--~----~

2. Multiple ItemizedOverlay conflicts

Searched around and haven't seen anyone complaining about this so I
guess I'll toss it out.  Our app uses a MapView and we create 4
instances of a custom ItemizedOverlay object and add all to the
MapView overlays.

Our app creates events and based on the event type, adds it to the
appropriate instance of the custom ItemizedOverlay.  Everything
displays fine, they each have a different marker so its easy to see
one set versus another.  The custom ItemizedOverlay has an overridden
onTap(int index) to show a Toast with some info about the item.

The problem occurs once there are events in 2 or more of the custom
ItemizedOverlay instances.  Tapping one of the markers causes the
other ItemizedOverlays to respond to onTap as well, regardless of
whether they are close on the map or not.

Has anyone seen anything like this?  Found a way around it?  I'm
wondering if the problem is the fact that all 4 instances are of the
same type but it still seems strange behavior.  Thoughts anyone?

Thanks,
Derek
--~--~---------~--~----~------------~-------~--~----~

3. PhoneStateListener question

4. MediaPlayer Internal Errors when streaming mp3 from ftp site...

5. How to use a CSR Wi-Fi Chip in Android?

6. Visual Voice mail

7. Dynamic Widget Size