I am doing a custom title for my android app and I want to have a refresh button like the Twitter app.
I am using a RelativeLayout an my ImageView is defined by:
<ImageView android:id="@+id/title_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_menu_refresh"
android:layout_alignParentRight="true">
</ImageView>
In my Activity I have something like this:
refreshView = (ImageView) findViewById(R.id.title_refresh);
refreshView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
/* Make the refreshView turn into a progress bar. */
startService(new Intent(MyActivity.this, MyService.class));
}
}
I would like the ImageView to turn into a ProgressBar while I wait for my service to finish processing. How is the correct way to do this?
You could add the progress bar view into the RelativeLayout which overlaps the ImageView with visibility:gone and then play with setVisibilty(View.VISIBILE)/setVisibilty(View.GONE) on your ImageView and ProgressBar.
Maybe a ViewSwitcher could help you too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With