0

I have a algorithm that need about 4-5 sec to get all the contacts from sim and bind them in my autocompletetextview (which happens in onCreate) so while that happens how can i create a dialog that will show like loaing and percentage or a progress bar... pls some reference or help:D

1

3 Answers 3

1

you have to used the ProgressDialog: http://developer.android.com/reference/android/app/ProgressDialog.html

It can show a indeterminate progress bar or a percentage. To update the percentage bar, you'd possibly need to use the class AsyncTask. I put a link which shows the two classes working together: http://sites.google.com/site/androidhowto/how-to-1/asynctasks-with-progressdialogs

I'm adding a more useful link: http://www.codeproject.com/Articles/162201/Painless-AsyncTask-and-ProgressDialog-Usage

Sign up to request clarification or add additional context in comments.

Comments

0

Use AsyncTask, it has helpful methods namely

      protected void onPreExecute(){
        //Show a dialog here
     }
      protected void onProgressUpdate(Integer... progress) {
         setProgressPercent(progress[0]);
     }

     protected void onPostExecute(Long result) {
         showDialog("Downloaded " + result + " bytes");
     }

You can publish your percentage progress in onProgressUpdate method and in onPostExcecute dismiss the dialog

Comments

0

You should write the part updating the progressbar as an AsyncTask to see the loading lively. You can also use Handlers.

this can help: http://developer.android.com/reference/android/os/AsyncTask.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.