12

I added a progressbar to my app but I want to hide it after some doing some action,

I used hide(), dismiss() and cancel()... but none of them work?

How can I hide the progressbar?

onexf
  • 3,674
  • 3
  • 22
  • 36
Adham
  • 63,550
  • 98
  • 229
  • 344
  • Please mention the class you are using. I assume it is: android.widget.ProgressBar, but it does not have hide(), dismiss() or cancel() methods. Have you tried View.GONE. Your question is very old. – Abhinav Saxena Mar 08 '19 at 08:12

6 Answers6

34
ProgressBar.setVisibility(View.INVISIBLE) 

should be enough.

Edit: fixed typo.

Leandros
  • 16,805
  • 9
  • 69
  • 108
Jake Kalstad
  • 2,045
  • 14
  • 20
5

"all of them are work", that sounds like it means that they work? But then why the question?

I'd say: get the view, en do

 myView.setVisibility(View.GONE)
Nanne
  • 64,065
  • 16
  • 119
  • 163
3
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setVisibility(0);    --visible
progressBar.setVisibility(4);    --invisible
progressBar.setVisibility(8);    --gone (like dismiss)
Stephanie
  • 55
  • 1
3

KOTLIN

progressBar.visibility = View.GONE
Álvaro Agüero
  • 4,494
  • 1
  • 42
  • 39
1

when you want to show it
progressBar.visibility = View.VISIBLE


when you want to hide it
1 progressBar.visibility = View.GONE
2 progressBar.visibility = View.INVISIBLE
0

1). first make a variable to access progress bar => ProgressBar progBar;

2). Initialize it to id given to the progressbar view => progBar = findViewById(R.id.ID_OF_PROGRESS_BAR);

3). Now, set the visibility => progBar.setVisibility(View.GONE);

full code =>

ProgressBar progBar;
progBar = findViewById(R.id.ID_OF_PROGRESS_BAR);
progBar.setVisibility(View.GONE);