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

  • Home
  • SEARCH
  • 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 943543
In Process

The Archive Base Latest Questions

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

I am using a progress bar in android, so that till my data is

  • 0

I am using a progress bar in android, so that till my data is loaded, user is getting a proper feedback of what is going on.
the code for the bar is below:

final ProgressDialog myProgressDialog;

myProgressDialog = ProgressDialog.show(ListingPage.this,"Please Wait", "Loading Date", true);
new Thread() {
   public void run() {
      try{
         setSelected();                     
         sleep(5000);
      } catch (Exception e) { }
      myProgressDialog.dismiss();
   }
}.start();

The setSelected() method is inserting data into an array list, and then creating an array adapter and then using a list view to show those items.

so when I put the setSelected() method in progress bar, it shows the loading circle, but once loading is done. Nothing is displayed in listview. But if I take out progress bar code (thread and run method), and simply call setSelected() method, the listview successfully declares the data.
so far it concludes that the progress bar code is doing some thing…so wanted to know am I missing something to add in or take out from the code. I need to the show progress bar as I am reading data from online source and it takes time , which may make user uncomfortable.

  • 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-15T22:27:13+00:00Added an answer on May 15, 2026 at 10:27 pm

    The Problem could be that you are trying to change the Userinterface from another thread then the UI thread, this is not possible in Android.

    I would suggest to try the use of an Async Task. Asynct Task gives you the possibility to do something in a background thread and publish the results in the UI thread after it is done.

    For this I would separate the setSelected Method in two Methods one that gets the data and creates the Array and everything else and one that creates the adapter and publishes the results to the list.

    myProgressDialog = ProgressDialog.show(ListingPage.this,"Please Wait", "Loading Date", true);
    
    final Result[] results = new Result[]();
    
    new AsyncTask<Void, Void, Void>() {
    
        //This is done in the background
        protected Void doInBackground(Void... params) {
           results = getResults();
           return null;
        }
    
        //This id done in the UI Thread
        protected void onPostExecute(Long result) {
           publishResults();
           myProgressDialog.dismiss();
        }
    
       }
    }.execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As I created a Progress bar using below code in a on click method
I am using the below code to update my progress bar. ProgressBar.Visible = true;
I'm using a progress bar to display the battery status. If the user clicks
I have a WPF project using CM. I have a progress bar that I
Can I use progress bar in android, without the thread? HERE IS CODE OF
I am using following code, but my progress bar is not displaying in the
In my application i am doing some process using progress bar at that time
I'm using an horizontal progress bar in my Android application, and I want to
Hi i'm using Rotating Progress Bar in my Android Music Plyer Application....I'm not able
I'm trying to make a simple progress bar using the width property of an

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.