Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 939627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:49:13+00:00 2026-05-15T21:49:13+00:00

I have a little problem, I hope U can help me;) Trouble is, that

  • 0

I have a little problem, I hope U can help me;)

Trouble is, that ProgressDialog show only after loading run(), but I need to show it on start and showing it while loading some data. I put: “dialog = ProgressDialog.show(CategoriesListActivity.this,”Working…”,”Loading data”, true);” in method run(), but the same. I print in Log.i() some info (int i++) and put title of ProgressDialog. Method work correctly, but don’t show ProgressDialog. I have read some info that some thread block another thread (my created), that’s why doesn’t show progressDialog, but can’t do anything. Thx.

    public void run() {

        /** getting there long execution **/
        handler.sendEmptyMessage(0);

    }

    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {

            // stop and hide dialog
            dialog.dismiss();
        }
    };

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.list_

        dialog = ProgressDialog.show(CategoriesListActivity.this, "Working...",
                "Loading data", true);

        // start new thread where get long time execution
        Thread thread = new Thread(this);
        thread.start();

        //wait while data is loading, 'cause I need use variable from calculation
                // in "EfficientAdapter" later
        try {
            thread.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        ListView l1 = (ListView) findViewById(R.id.list);
        l1.setAdapter(new EfficientAdapter(this));
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T21:49:14+00:00Added an answer on May 15, 2026 at 9:49 pm

    That’s done with the help of AsyncTask (an intelligent backround thread) and ProgressDialog

    When the AsyncTask starts we raise a progressdialog with indeterminate state, once the task is finished we dismiss the dialog.

    Example code
    What the adapter does in this example is not important, more important to understand that you need to use AsyncTask to display a dialog for the progress.

    private class PrepareAdapter1 extends AsyncTask<Void,Void,ContactsListCursorAdapter > {
        ProgressDialog dialog;
        @Override
        protected void onPreExecute() {
            dialog = new ProgressDialog(viewContacts.this);
            dialog.setMessage(getString(R.string.please_wait_while_loading));
            dialog.setIndeterminate(true);
            dialog.setCancelable(false);
            dialog.show();
        }
        /* (non-Javadoc)
         * @see android.os.AsyncTask#doInBackground(Params[])
         */
        @Override
        protected ContactsListCursorAdapter doInBackground(Void... params) {
            cur1 = objItem.getContacts();
            startManagingCursor(cur1);
    
            adapter1 = new ContactsListCursorAdapter (viewContacts.this,
                    R.layout.contact_for_listitem, cur1, new String[] {}, new int[] {});
    
            return adapter1;
        }
    
        protected void onPostExecute(ContactsListCursorAdapter result) {
            list.setAdapter(result);
            dialog.dismiss();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem, and I hope you can help me. I'm porting
I have a little DB challenge for you. Hopefully you can help. The Problem:
I have a little problem and because my WEB development skills are not the
I have a little problem. I don't know how to use the DataSet in
I have got a little problem. I got a bxslider running on a website
I just started learning objective c. I have this little problems and questions, hope
Goodday, I have a little problem finishing off a project. I am not very
I have a little contact-page on my asp.net page. I have ~5 validators that
I'm currently trying Backbone.js along with a rails app. My problem is, that I
I hope you forgive me if I'm a little confused about this. Jrails rewrites

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.