F
F
freshcot2015-01-13 17:12:20
Java
freshcot, 2015-01-13 17:12:20

How does progressbar work in android?

Such a question has ripened, there is a handling of the button click event:

pbLoader2 = (ProgressBar) findViewById(R.id.progressBar);
===много кода====
  public void onClick(View v) {
        Bitmap bitmap = ((BitmapDrawable) fullImageView.getDrawable())
        .getBitmap();
    switch (v.getId()) {
    case R.id.llDownloadWallpaper:
                         pbLoader2.setVisibility(View.VISIBLE);
       utils.saveImageToSDCard(bitmap);
       break;
    case R.id.llSetWallpaper:
                        pbLoader2.setVisibility(View.VISIBLE);
 			utils.setAsWallpaper(bitmap);
      break;
    default:
      break;
    }
  }

If you leave the code in this form, then pbLoader2 will appear not when you click, but earlier, but if you insert pbLoader2.setVisibility(View.GONE); the progressbar will not appear at all.
How can I make the progressbar appear when the button is clicked and disappear after the case is
completed

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
IceJOKER, 2015-01-13
@IceJOKER

Tabulation in the code is terrible, which is inconvenient to read.
By default, set the android:visibility of the progressbar to invisible or GONE, when clicked, set the value to VISIBLE and that's it.

K
Kolya Kiselyov, 2015-01-18
@dominqnta

pbLoader2.setProgress(0 to 100);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question