I am developing an android application in which I want to slide images with finger touch. I have implemented an onClickListener
with which I can slide images but I
What you are looking for is an ViewFlipper
. This will help you to get the look what you are expecting.
This mgiht be helpful
check this too
Or try this,
In your xml just add only this,
need not enclose with any ImageViews.
Now do this in your coding.
Considering that you have stored your Images in a array like this,
int gallery_grid_Images[]={R.drawable.gallery_image_1,R.drawable.gallery_image_2,R.drawable.gallery_image_3,
R.drawable.gallery_image_4,R.drawable.gallery_image_5,R.drawable.gallery_image_6,R.drawable.gallery_image_7,
R.drawable.gallery_image_8,R.drawable.gallery_image_9,R.drawable.gallery_image_10
};
Now in your onCreate(),
viewFlipper = (ViewFlipper) findViewById(R.id.flipper);
for(int i=0;i
And now add this method to your activity,
private void setFlipperImage(int res) {
Log.i("Set Filpper Called", res+"");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
viewFlipper.addView(image);
}
That's it. And now using your viewFlipper.showNext();
and viewFlipper.showPrevious();
methods you can show your dynamic images.