Nikunj Patel
Nikunj Patel

Reputation: 22066

OnClickListener of ImageButton android

I have implement one application in which four image button and on image button has four animal picture like this :

 deer.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
           .. . .. . . .
    });
 Fox.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
           .. . .. . . .
    });
 lion.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
           .. . .. . . .
    });
 monkey.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
           .. . .. . . .
    });  

Now problem is when i am click on lion , other 3 clickListner are not disable.so when user click on lion at that time click on deer flag will true both. or some time flag will true all.

in simple language i want disable remain clickListner if i am click on any one.

so can you help me.?

Upvotes: 3

Views: 6924

Answers (2)

sat
sat

Reputation: 41076

Each image button has different listeners , so it should not call other listeners other than the buttons you are touching. May be you have to reset the flags depending on your implementation.

Upvotes: 0

Rasel
Rasel

Reputation: 15477

deer.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
    Fox.setClickable(false);
    Lion.setClickable(false);
    Monkey.setClickable(false);

           .. . .. . . .
    });

Upvotes: 1

Related Questions