Wednesday, November 21, 2012

Button in ListView

Many thanks to Adam Toennis who directed me to this stack overflow post that helped resolve an ugly problem.  I'm posting it here so that when I run into this again in 6 months, I can find it easily.

Problem was that we put a button in a list view row.  We obviously want the user to be able to tap the button, but we still wanted the user to tap the row itself too.  Just putting the button in clobbered the row tap.

Answer came from this post: http://stackoverflow.com/questions/3045872/listview-and-buttons-inside-listview

In short,  put android:focusable="false" in the button element.