-2

Shopping Flyer A viewpager contain a firebase image.This image contain many small different images.When I touch a small image I have to display to another activity.how to proceed to achieve this ?

Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
  • Please refer this link. [https://stackoverflow.com/questions/11312128/get-the-touch-position-inside-the-imageview-in-android](https://stackoverflow.com/questions/11312128/get-the-touch-position-inside-the-imageview-in-android) – Deepak Rajput May 16 '19 at 04:26

1 Answers1

0

Use a GridLayout, with ImageView children. Use the onClickListener of the ImageView when they were added to the GridLayout to determine which image was clicked.

You don't need to know the coordinates of the image. Because the ImageView has its own space.

        GridLayout gridLayout;
        ArrayList<MyImage> myImages; // MyImage model should contain the image and information about the product

        for (MyImage myImage : myImages) {
            ImageView imageView = new ImageView(this);
            imageView.setImageBitmap(myImage.getImageBitmap());
            imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {

                    // start your details activity here

                }
            });
            gridLayout.addView(imageView);
        }

Israel dela Cruz
  • 794
  • 1
  • 5
  • 11
  • deal .for example I have say 30 shopping flyer,each page contain many products. user need to swipe from first to last page. if he found some interesting product he will touch and that should displayed in the next activity. so at same time it can be swipable whole page as well as clickable individual product.is it possible using grid layout? – Javad Ahamad May 16 '19 at 08:12
  • Yeah, you can wrap it in a PagerView. Does the product have its own image or are there multiple product in a single image? – Israel dela Cruz May 16 '19 at 16:26
  • .yeah.all the individual product images will be uploaded to firebase for other purposes. my idea was getting the coordinates of the touched images and call the already uploaded images from firebase. – Javad Ahamad May 16 '19 at 21:24
  • I've edited my answer to show you that you don't need the coordinates of the image because the ImageView that contains it has its own click listener. – Israel dela Cruz May 16 '19 at 21:37
  • I think I have to clarify my question a little bit. please watch this video.https://m.facebook.com/story.php?story_fbid=10155985464981751&id=525001750 – Javad Ahamad May 16 '19 at 22:33
  • I can't see it. So you just want the x,y coordinate of the touch event? – Israel dela Cruz May 17 '19 at 00:53