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 8308259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:45:09+00:00 2026-06-08T18:45:09+00:00

I have a search function (using a web service) which takes a while to

  • 0

I have a search function (using a web service) which takes a while to load data to my inflated layout. I want to show a ProgressBar untill the data is fetched from the web service. This is a small time interval and hence I don’t to use a ProgressDialog for this. I’ve gone through many posts and dev guide but I’m not able to figure out a way to use that in my app. I’ve a Spinner in my layout. Once I choose an item from the spinner drop down I pass the string to the search function which fetches as well as loads data into the inflated layout.

spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
        Selection = spinner.getSelectedItem().toString();           

        search(Selection);
    }

I created a ProgressBar, handler as explained in the dev guide.

private ProgressBar mProgress =  new ProgressBar(SearchActivity.this, null, android.R.attr.progressBarStyleSmall);
private int mProgressStatus = 0;

private Handler mHandler = new Handler();

And say this is a new thread used to display the ProgressBar

new Thread(new Runnable() {
         public void run() {
             while (mProgressStatus < 100) {
                 mProgressStatus = doWork();

                 // Update the progress bar
                 mHandler.post(new Runnable() {
                     public void run() {
                         mProgress.setProgress(mProgressStatus);
                     }
                 });
             }
         }
     }).start();

How do I track progress of my search function to show the ProgressBar?

Thank you for reading

  • 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-06-08T18:45:10+00:00Added an answer on June 8, 2026 at 6:45 pm

    Use an AsyncTask instead of a thread. It’s way easier to use and provides a built-in mechanism to be notified of progress updates.

    Look at this question for a complete sample :

    Download a file with Android, and showing the progress in a ProgressDialog

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application with lots of data, and a search/filter function with
i'm using autocomplete from jquery... and i have this: $('#name_search').autocomplete({ source: search/name.php, open: function(){
I have a search function in which i am returning all the records of
hai I have a magento web site. In this the search function compare with
I have this 'web service' I made that when accessed: http://192.168.0.1/api/v1/search/?query=thequery returns a JSON
In my web app , i am using jquery ui autocomplete which data are
I have implemented search by map function on my web-site. The map have some
I have a search function in my project. In the searchable.xml, i would like
I have a binary search function that will search for a word in an
I have created a Google Search function, however I would like to leave the

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.