1

It's easy to make a row in a ListView do something when it is clicked. But add something else in the row--such as a Button or other control--that has an OnClickListener, and suddenly nothing happens when the row is clicked.

Before you close this question as a duplicate, I am perfectly aware that there are a number of StackOverflow questions about that. They generally either recommend setting the Button android:focusable="false" or setting android:descendantFocusability="blocksDescendants" on the ViewGroup containing the row Views.

These work, but one problem: if you're navigating with the keyboard (tabbing or arrow keys), it skips right over the Button.

Is there a way to solve the issue and allow people to "click" either row or Button without having to actually tap the touchscreen?

Chad Schultz
  • 7,770
  • 6
  • 57
  • 96

1 Answers1

0

Setting an OnClickListener on each row (instead of setting an item click listener for the ListView) did not help.

I did find some more info, such as using ListView.setItemsCanFocus(true) Using Android, how can I select rows from a ListView which contains Button controls and using beforeDescendants Focusable EditText inside ListView but can't get both the row and the button to be usable with a keyboard.

BUT it occurred to me to try and test out Gmail with a keyboard. I can't find a way to mark a row as a favorite (select the star). So apparently even they aren't making it fully accessible! Oh well. A lose cause I suppose.

Community
  • 1
  • 1
Chad Schultz
  • 7,770
  • 6
  • 57
  • 96