我有一个相当复杂的的ListView
。每个项目看起来是这样的:
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)
在我的活动,在创建项目时( getView()
称)我添加动态的TextView
取值到的LinearLayout
在 HorizontalScrollView
(除了填充其他的,更简单的东西了)。令人惊讶的,性能pretty的好。
In my activity, when an item is created (getView()
is called) I add dynamic TextView
s to the LinearLayout
inside the HorizontalScrollView
(besides filling the other, simpler stuff out). Amazingly, performance is pretty good.
我的问题是,当我加入了 HorizontalScrollView
,我的列表中的项目变得不可点击。他们没有得到橙色背景点击时,他们不火 OnItemClickedListener
我已经设置了(做了一个简单的 Log.d
电话)。
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?
编辑:设置安卓descendantFocusability =blocksDescendants
在最上面的的LinearLayout
似乎工作。我想知道是否有其他的方法,虽然:?如果我想在我的列表中的项目可成为焦点的项目
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?
使用安卓descendantFocusability =blocksDescendants
在最上面的的LinearLayout
的伎俩。里面的元素仍可以点击,他们只是没有作为焦点(即你不能按他们的非触摸屏设备上)。好足够了。
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.