Reputation: 19
I have a button in my application. I would like to a show progress dialog replacing the button, after clicking it.
How would I do that?
Upvotes: 0
Views: 406
Reputation: 626
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</FrameLayout>
On button click:
findViewById(R.id.button).setVisibility(View.GONE)
findViewById(R.id.progressbar).setVisibility(View.VISIBLE)
Upvotes: 2
Reputation: 11
You can create the button and the progress bar at the same location through layout xml and set
the progress bar's visibility as GONE
.
Now in the onClick()
method of button, set
button.setVisibility(View.GONE)
progressbar.setVisibility(View.VISIBLE)
Upvotes: 1