tags:

views:

54

answers:

2

Can I make ImageView in android make some action when I click on that ImageView ? For example, when I click on ImageView imgV that some panel be visible and when I click on other ImageView imgUV that he become unvisible .

imgV.setOnClickListener( new OnClickListener() {
            public void onClick(View v)
            {
                    int i=tbrSearchNear.VISIBLE;
                    tbrSearchNear.setVisibility(1-i);
                    tbrSearchCriterium.setVisibility(i);

            }

            });

It looks like that doesn't register click at all .

+2  A: 

Maybe ImageButton is what you are looking for? http://developer.android.com/reference/android/widget/ImageButton.html

Sotapanna
A: 

Setting visbility to 1-View.VISIBLE translates to 1-0; if you want to hide it, write something like:

    imgV.setOnClickListener( new OnClickListener() {
        public void onClick(View v)
        {
                // toggle visibility
                int visibility=tbrSearchNear.getVisbility() == View.VISIBLE ? View.GONE : View.VISIBLE;
                tbrSearchCriterium.setVisibility(tbrSearchNear.getVisbility());
                tbrSearchNear.setVisibility(visbility);

        }

        });
junkdog