D
D
druper2020-07-25 07:44:46
Android
druper, 2020-07-25 07:44:46

How to hang OnClickListener on CardView so that it works on all elements except one?

The ImageView will have its own handler.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2020-07-25
@druper

Duc put two clicklisteners, on the container and on the view.

A
alekseyHunter, 2020-07-25
@alekseyHunter

Hang on all elements inside OnClickListener (TextView, ImageView, etc.)
Or parse the Id of the clicked View, as an option.

View.OnClickListener myOnlyhandler = new View.OnClickListener() {
  public void onClick(View v) {
      switch(v.getId()) {
        case R.id.b1:
          // it was the first button
          break;
        case R.id.b2:
          // it was the second button
          break;
      }
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question