1

I am a newbie in android. I want to make an application that show dialog loading when I get data from server. I want my loading screen such as this picture below: Loading Screen

I don't know any key to searching to make this loading :(. Is This application show in the picture using progress bar with animation?. I have some picture when I extract apk file of this application and I have some pictures as below: enter image description here

enter image description here

Xiao King
  • 369
  • 1
  • 13
  • I think that you can found some template in this site http://www.material.uplabs.com/ – Yagami Light Aug 21 '16 at 13:29
  • @YagamiLight thanks you bro. But I don't see anything like this :(. Moreover I don't want to use other library, I want to custom it :( – Xiao King Aug 21 '16 at 13:38
  • the problem is that in my office i can't see images (proxy .. ) but to understand your problem you want to do a simple loading circle or an activity – Yagami Light Aug 21 '16 at 13:46
  • @YagamiLight no bro. I can make simple loading circle. I don't know how I can explain for u understand. U will understand what I need when u see my pictures upload above :( – Xiao King Aug 21 '16 at 13:49

2 Answers2

0

try this.

in run() put code which rewrite your progressbar...

if you want stop timer. use timer.cancel(); and for example start faster timer for finish progress..

imer timer= new Timer();
     timer.schedule(
                    new TimerTask() {
                        @Override
                        public void run() {
                            runOnUiThread(
                                    new Runnable() {
                                        @Override
                                        public void run() {

                                    **thise code run every 100ms**

                                }
                            }
                    );
                }
            }, 0, 100);

it's simply, if you want correctly resolve thise problem use Threats.

  • thanks you, but I just dont know how I can make my progress bar display as my picture show above :(. Your code just repeat an action per 100ms. I using ansytask to get data from server and display progress when download. I want my progress bar display as picture I showing above. – Xiao King Aug 21 '16 at 13:53
  • you have grafic for it? or it's only suggestion – user6651666 Aug 21 '16 at 14:04
  • grafic? what do you mean ? – Xiao King Aug 21 '16 at 14:10
  • pictures. png file ... what you want implement on the project. – user6651666 Aug 21 '16 at 14:24
  • pictures. I think I found solution for my question. http://stackoverflow.com/questions/19900747/custom-progress-dialog-with-squre-image-rotation-with-asyntask. This is exactly what I want :). Thanks you for your answer. – Xiao King Aug 21 '16 at 14:49
0

Have you tried using AsyncTask?

You should look on Android Threading concepts. and as mentioned remember runOnUiThread for calls that updates your UI.

You should extend a progressbar and handle the images position on it... Here is the AsyncTask example code:

 private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
 protected Long doInBackground(URL... urls) {
     int count = urls.length;
     long totalSize = 0;
     for (int i = 0; i < count; i++) {
         totalSize += Downloader.downloadFile(urls[i]);
         publishProgress((int) ((i / (float) count) * 100));
         // Escape early if cancel() is called
         if (isCancelled()) break;
     }
     return totalSize;
 }

 protected void onProgressUpdate(Integer... progress) {
     setProgressPercent(progress[0]);
 }

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

}

Rock_Artist
  • 555
  • 8
  • 14
  • Thanks you bro. I know how can make progress bar to display percent download file. But I want custom dialog progress bar as picture. And I found solution for my problem here. http://stackoverflow.com/questions/19900747/custom-progress-dialog-with-squre-image-rotation-with-asyntask . – Xiao King Aug 21 '16 at 14:50