views:

240

answers:

1

I have quite a complicated ListView. Each item looks something like this:

> LinearLayout (vertical)
  > LinearLayout (horizontal)
    > include (horizontal LinearLayout with two TextViews)
    > include (ditto)
    > include (ditto)
  > TextView
  > HorizontalScrollView (this guy is my problem)
    > LinearLayout (horizontal)

In my activity, when an item is created (getView() is called) I add dynamic TextViews to the LinearLayout inside the HorizontalScrollView (besides filling the other, simpler stuff out). Amazingly, performance is pretty good.

My problem is that when I added the HorizontalScrollView, my list items became unclickable. They don't get the orange background when clicked and they don't fire the OnItemClickedListener I have set up (to do a simple Log.d call).

How can I make my list items clickable again?


Edit: setting android:descendantFocusability="blocksDescendants" on the topmost LinearLayout seems to work. I'd like to know if there are other ways, though: what if I want focusable items in my list items?

+1  A: 

Using android:descendantFocusability="blocksDescendants" on the topmost LinearLayout did the trick. Elements inside can still be made "clickable", they're just not focusable (i.e. you can't click them on a non-touchscreen device). Good enough for me.

Felix