0

I have a gallery with bunch of images. I'm able to perform onItemClick for one image. But I want to add left/right buttons to get the pervious/next image. How can I do that? Below is the code for onItemClick

@Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
                                int position, long arg3) {

            ModelGallery model = (ModelGallery) mListView.getItemAtPosition(position);

            Intent intent = new Intent(getActivity(), GalleryActivity.class);
            startActivity(intent);

Here's the activity class. Loading the image from the URL passed from the Fragment class.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gallery);

    final ImageView imageView = (ImageView) findViewById(R.id.full_image);

    final String imageUrl = getIntent().getStringExtra("imageURL");

    Ion.with(imageView)
            .placeholder(R.drawable.ic_loading)
            .error(R.drawable.ic_error)
            .load(imageUrl);

}
Le_Master
  • 147
  • 1
  • 2
  • 20

1 Answers1

0

here are some links which will help you to solve your problem.

http://codetheory.in/android-image-slideshow-using-viewpager-pageradapter/

as gallary class get depricated : (Ref : http://developer.android.com/reference/android/widget/Gallery.html ) you have to you horizontal-scrollview with view pager class (Ref : http://developer.android.com/reference/android/widget/HorizontalScrollView.html) (Ref : http://developer.android.com/reference/android/support/v4/view/ViewPager.html)

And one more thing that you have to intent while list of URLs of images in second activity. not just one URL of image. hope it will help you.

Dharvik shah
  • 1,969
  • 12
  • 27