What I think might be a more appropriate way of achieving this, is
sending a message from the runnable through the Handler to the main UI
thread to then launch the dialog.

I think the reason your getting the message in Eclipse is that Dialogs
are closely tied with the Activities that launch them (I think it's
due to the activity life cycle).
Anyway because of this, you pass AlertDialog.Builder 'this' rather
than 'getApplicationContext()'. I can't tell from your code what
you've passed to your Runnable (although I think this would cause a
runtime error rather than a eclipse undefined error).

Try out these two things and hopefully you'll be able to get it
working.

Cheers,
Matt

On Feb 25, 2:52 pm, Michael Davey <frak....@gmail.com> wrote:
> Hi there,
>
> I have an action from a button click that performs a lengthy web based fetch, 
> so I have implemented it as a Runnable that is called from a Handler in my 
> Activity class.  However, in certain situations I need to be able to present 
> the user with an alert dialog, which from the docs seems to require a Context 
> object on it's constructor.  This was not visible from the inner class, so I 
> created a new class that implements Runnable that I pass the context to in 
> it's constructor as follows:
>
> import android.app.AlertDialog;
> import android.content.Context;
>
> public class ActivityRunnable implements Runnable {
>
>         public Context mContext;
>         public AlertDialog mAlert;
>
>         public ActivityRunnable(Context ctx) {
>                 mContext = ctx;
>         }
>
>         @Override
>         public void run() {
>                 // TODO Auto-generated method stub
>
>         }
>
> }
>
> However, in my code that instantiates this class, and implements run(), I try 
> and run the following code:
>
> mAlert = AlertDialog.Builder(mContext).create();
>
> However, I get an error from Eclipse saying that the method Builder(Context) 
> is undefined for the type AlertDialog - has anyone else encountered this 
> problem, or know of a better solution to my problem?
>
> regards,
>
> frak

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to