Reputation: 1185
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
Upvotes: 0
Views: 2197
Reputation: 2844
You should write the part updating the progressbar as an AsyncTask
to see the loading lively. You can also use Handler
s.
this can help: http://developer.android.com/reference/android/os/AsyncTask.html
Upvotes: 0
Reputation: 8604
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
Upvotes: 0
Reputation: 484
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
Upvotes: 1