Turning a refresh ImageView into a ProgressBar

Posted by Macarse on Stack Overflow See other posts from Stack Overflow or by Macarse
Published on 2010-05-19T20:26:41Z Indexed on 2010/05/19 20:30 UTC
Read the original article Hit count: 274

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about android

Related posts about progressbar