After thinking for hours I came up with solution as none of the answers helped me.
- Load the Imageview
- onclick will change the imageview image with an Animation .
Java Code
public class ImagePreviewActivity extends Activity implements OnClickListener {
public int currentimageindex=0;
private int[] IMAGE_IDS ={R.drawable.splash1, R.drawable.splash2, R.drawable.image_preview, R.drawable.report_incident_exclamation_mark};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.media_preview);
ImageView imageview = (ImageView)findViewById(R.id.ImageViewPreview);
imageview.setImageResource(R.drawable.splash1);
currentimageindex++;
imageview.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Animation inFromRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(500);
ImageView imageview = (ImageView)findViewById(R.id.ImageViewPreview);
imageview.startAnimation(inFromRight);
if ((IMAGE_IDS.length)> currentimageindex){
imageview.setImageResource(IMAGE_IDS[currentimageindex]);
currentimageindex++;
}
}
}