I have done this using animation drawable. Here are the steps:
Animate drawable ic_sync_drawable.xml:
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selected"
android:oneshot="false">
<item
android:drawable="@drawable/ic_popup_sync_1"
android:duration="50" />
<item
android:drawable="@drawable/ic_popup_sync_2"
android:duration="50" />
<item
android:drawable="@drawable/ic_popup_sync_3"
android:duration="50" />
<item
android:drawable="@drawable/ic_popup_sync_4"
android:duration="50" />
<item
android:drawable="@drawable/ic_popup_sync_5"
android:duration="50" />
<item
android:drawable="@drawable/ic_popup_sync_6"
android:duration="50" />
</animation-list>
Now in java code I am using ImageView:
Drawable drawable = getContext().getResources().getDrawable(R.drawable.ic_sync_drawable);
ImageView imageView = new ImageView(getContext());
imageView.setImageDrawable(drawable);
imageLoader.get(imageurl, ImageLoader.getImageListener(imageView, 0, 0));
ViewFlipper.addView(imageView);
//start animation
AnimationDrawable frameAnimation = (AnimationDrawable) drawable;
frameAnimation.start();