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 no开发者_高级运维ne of them work?
How can I hide the progressbar?
ProgressBar.setVisibility(View.INVISIBLE)
should be enough.
Edit: fixed typo.
"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)
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.setVisibility(0); --visible
progressBar.setVisibility(4); --invisible
progressBar.setVisibility(8); --gone (like dismiss)
KOTLIN
progressBar.visibility = View.GONE
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
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);
精彩评论