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. "toplevel" in traceview. What is it?

When I run traceview on my application and the data file the first
method in the method profiler just says (toplevel) and when you click
on it nothing happens (there are no parents no children).
What is this? And do I need to worry about it. It reports some crazy
amount for time/call 3205 the highest in the app.

Any ideas? My application runs very slow when displaying a Google map
with several (6 - 12) routes in a pathOverlay. When I remove the
routes performance is better but still way too slow.


--~--~---------~--~----~------------~-------~--~----~

2. Remove text on ViewMap

Is there a way to remove the text: country names etc.. From a MapView ?
--~--~---------~--~----~------------~-------~--~----~

3. LocationManager: getLastKnownLocation and getBestProvider broken?

4. Length of text drawn in pixel?

5. How to connect with remote app without good ServerSocket?

6. getScale() method of BaseAdapter class Question!

7. Error recieving broadcast null in LocationIntentReciever