Problem with ProgressDialog

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Problem with ProgressDialog

Postby rustyventure » Fri Mar 13, 2009 10:55 pm

(Note: I posted this to android-beginners this morning, but no replies yet, so I'm trying here too :) )

Hi, Everyone:

I'm having some trouble displaying a ProgressDialog. Basically, I want
to show a progress "popup" when a user presses a button in my app.
Here's the code:

Code: Select all
OnClickListener updateButtonPressed = new OnClickListener(){
        // @Override
        public void onClick(View arg0) {
                //Run this on a new thread
                runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                                // TODO Auto-generated method stub
                                ProgressDialog pd = null;
                                pd = ProgressDialog.show(myContext, "please wait", "updating",
true, false);
                                /*
                                 run a bunch of code ...
                                */
                                pd.dismiss();
                        }
                });
        }
    };


The code runs fine, but the popup never appears. I'm using Eclipse as
my development environment, and it logs no errors. As far as I can
tell (and from some google searches), the ProgressDialog should work,
so I'm stumped. Any ideas?
rustyventure
Freshman
Freshman
 
Posts: 5
Joined: Wed Dec 10, 2008 12:14 am

Top

Postby MrSnowflake » Sat Mar 14, 2009 10:23 am

That's probably because /* run a bunch of code */ should be in a separate thread.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests