我有一个在中心使用 HorizontalScrollView
A 的ListView
项目布局。我已经使用了android属性安卓descendantFocusability =我的父母blocksDescendants
的LinearLayout
,使的ListView
项目仍然选择。
I have a ListView
item layout that is using a HorizontalScrollView
in the center. I have used the android attribute "android:descendantFocusability="blocksDescendants"
" on my parent LinearLayout
so that the ListView
items are still selectable.
我遇到的问题是,点击的ListView
项目这是 HorizontalScrollView
,该部分时, 的ListView
产品Click事件不会被调用。
The problem I am having is that when clicking the part of the ListView
item which is the HorizontalScrollView
, the ListView
item click event is not called.
我怎样才能获得的点击事件的 HorizontalScrollView
致电的ListView
列表项的单击事件?
How can I get the click event of the HorizontalScrollView
to call the ListView
list item click event?
HorizontalScrollView没有的onClick(),看到这个 的http://developer.android.com/reference/android/widget/HorizontalScrollView.html
HorizontalScrollView doesn't have "onClick()", see this http://developer.android.com/reference/android/widget/HorizontalScrollView.html
它支持的手势,并有的onTouchEvent(MotionEvent EV)
所以,你可以使用它作为点击。见跟随着演示,我甲肝prepared。
So you can use it as click. See followin demo which I hav prepared.
// Followin code will not work for HorizontalScrollView
/*hsv1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(HorizontalListActivity.this, tvMiddle.getText().toString().trim(), Toast.LENGTH_SHORT).show();
}
});*/
hsv1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Toast.makeText(YourActivity.this, "Your Msg", Toast.LENGTH_SHORT).show();
return false;
}
});