Displaying a ProgressBar when loading an image in ImageView?

Is there a way to "change" the view at runtime? Here is my goal: I want to display an animated indefinite view of the ProgressBar before loading my image. Is there a way to do this easily without having to do a bunch of crazy things? Is there a way to get the ProgressBar spinner animation resource id and just reuse it?

+4
source share
1 answer

Yes. I am trying to make a FrameLayout that contains both ImageView and ProgressBar . In onCreate() I do imageView.setVisibility(View.INVISIBLE) , and then after loading the image, I do:

 progress.setVisibility(View.INVISIBLE); imageView.setVisibility(View.VISIBLE); 

In terms of threading, you should always use AsyncTask . This is easily the most difficult part of the process, although it is still quite manageable. Check out this answer for a complete list of codes.

+16
source

Source: https://habr.com/ru/post/1343097/


All Articles