Sorry -- I took the OP literally, based on the sample code the OP provided. Inlining anonymous inner classes is a fine solution, if the only issue is keeping the code in close proximity to the code that configures the dialog.
On Sun, Oct 10, 2010 at 9:38 AM, Jonas Petersson <[email protected]> wrote: > On 10/10/2010 03:18 PM, Mark Murphy wrote: >> >> On Sun, Oct 10, 2010 at 9:12 AM, ecforu<[email protected]> wrote: >>> >>> Is there a way to get alert dialog results inline (like you can with most >>> dialogs)? >> >> Some platforms offer dialogs that block code execution in situ, others >> do not. Android does not. >> >>> I want to determine what to do next inwith a dialog, but I can't figure >>> out >>> how to get the results back in the same method that I create the dialog >>> from >>> thus allowing me to continue in my logic flow. >> >> You don't. >> >>> I want to keep it all in the same method. >> >> Sorry, but AFAIK that is not possible. > > Well, I guess it is a matter of taste, but you CAN put all the logic in one > method if you really want with something like this: > > > // Up here is some logic that suddenly needs to ask something, > // then: > new AlertDialog.Builder(this).setTitle("Important!") > .setMessage("The question"); > .setPositiveButton("Go ahead", > new DialogInterface.OnClickListener() { > public void onClick(DialogInterface arg0, int arg1) { > // Do the verified stuff > } > }) > .setNegativeButton("No way", > new DialogInterface.OnClickListener() { > public void onClick(DialogInterface arg0, int arg1) { > // Do some alternative stuff > } > }).show(); > > Maybe not exactly what you wanted and some may call it unreadable, but I'd > still mark it "possible"... > > YMMV / Jonas > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" 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-developers?hl=en > -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 3.0.1 Available! -- You received this message because you are subscribed to the Google Groups "Android Developers" 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-developers?hl=en

