I created a dynamic view that contains FrameLayout, and it contains ImageViews. Now, when I touch the particular image on frame layout, I want know the ID of the ImageView.
So, here are my questions:
How can I set the ID for the
ImageView?How can I recognize particular
ImageViewis touched?
Here is the sample snippet of the code:
for (int j = 0; j < _pageslist.size(); j++) {
    FrameLayout frame = new FrameLayout(HLActivity.this);
    LayoutParams params = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    frame.setLayoutParams(params);
    ImageView mainimage = new ImageView(HLActivity.this);
    mainimage.setImageBitmap(ReusableMethods.getBitmapFromURL(_pageslist.get(j)
            .getThumbnail().toString()));
    mainimage.setScaleType(ScaleType.FIT_XY);
    mainimage.setLayoutParams(params);
    frame.addView(mainimage, params);
    if (_pageslist.get(j).isHasspots()) {
        System.out.println(_pageslist.get(j).isHasspots());
        System.out.println(_pageslist.get(j).getSPOTS());
        ArrayList<Hotspot> hotspots_array = _pageslist.get(j).getSPOTS();
        for (int i = 0; i < hotspots_array.size(); i++) {
            Hotspot hotspot = hotspots_array.get(i);
            System.out.println("hotspot :: " + hotspot.getType());
            ImageView spotimage = new ImageView(HLActivity.this);
            spotimage.setBackgroundColor(Color.parseColor("#88676767"));
            float startx, starty, endx, endy;
            startx = (float) (Float.parseFloat(hotspot.getX()) * ivw) / 100;
            starty = (float) (Float.parseFloat(hotspot.getY()) * ivh) / 100;
            endx = (float) ((Float.parseFloat(hotspot.getX()) + 
                    Float.parseFloat(hotspot.getWidth())) * ivw) / 100;
            endy = (float) ((Float.parseFloat(hotspot.getY()) + 
                    Float.parseFloat(hotspot.getHeight())) * ivh) / 100;
            params = new FrameLayout.LayoutParams(
                    (int) ((Float.parseFloat(hotspot.getWidth()) * ivw)/100),
                    (int) ((Float.parseFloat(hotspot.getHeight()) * ivh)/100));
            params.leftMargin = (int) startx;
            params.topMargin = (int) starty;
            frame.addView(spotimage, params);
        }
    }
    _view.add(frame);
}
adapter = new ViewPagerAdapter(HLActivity.this, _view,
        _pageslist, ivw, ivh, getStatusBarHeight());
viewPager.setAdapter(adapter);