Response to alert dialog button programatically

Put your problem here if it does not fit any of the other categories.

Response to alert dialog button programatically

Postby sasuke » Mon May 12, 2008 3:26 pm

I have an alert dialog like this
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. new AlertDialog.Builder(mContext)
  3.  
  4. .setTitle("Testing")
  5.  
  6. .setMessage("Buy this thing?")
  7.  
  8. .setPositiveButton(R.string.yes, yesListener)
  9.  
  10. .setNegativeButton(R.string.no, noListener)
  11.  
  12. .show();
  13.  
  14.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


If we pressed the positive button, the program will run the yesListener and run the noListener if we pressed the negative button.

What i want is, if the program met certain condition, the alert dialog will show, and program automatically pressed the positive / negative button.

I don't want to access the method directly, because i want the dialog to be shown first... (it's done as if human pressed the button).

Is it possible?

Thanks,
sasuke
sasuke
Experienced Developer
Experienced Developer
 
Posts: 57
Joined: Fri Nov 30, 2007 1:25 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 24 guests