Search code examples
androidandroid-layoutandroid-gallery

Is it possible to add an ImageButton to images in a GalleryView?


I have a GalleryView which I want to add ImageButton to each image in the gallery. Is this possible to do since the GalleryView is expecting a touch event?


Solution

  • Yes, you can catch and ignore the onItemClick from the Gallery object and set an ImageButton to each image (with a custom adapter).

    Example:

    Gallery g = (Gallery) findViewById(R.id.gallery);
    g.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView parent, View v, int position, long id) {
                //do nothing
            }
        });