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.
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.
How can I get the click event of the HorizontalScrollView
to call the ListView
list item click event?
HorizontalScrollView doesn't have "onClick()", see this http://developer.android.com/reference/android/widget/HorizontalScrollView.html
It support gestures and have "onTouchEvent(MotionEvent ev)"
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;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With