I have a ListView where each row has a fixed height.
Every row contains, next to some images, a TextView.
Sometimes, the text I want to display is too large and henc
I can make this work by creating a subclass of ListView and override onTouchEvent as follows:
- I first check whether the MotionEvent is inside a childView
- if it is, I call the child's onTouchEvent
This does seem quite basic framework functionality so I'm surprised that this isn't handled by ListView itself. Am I missing something?
@Override
public boolean onTouchEvent(MotionEvent event)
{
//find correct child
View theChild = null;
boolean handled = false;
for (int i = 0; i < getChildCount(); i++)
{
View child = getChildAt(i);
Rect rect = new Rect();
child.getDrawingRect(rect);
offsetDescendantRectToMyCoords(child, rect);
if(rect.contains((int)event.getX(), (int)event.getY()))
{
theChild = child;
}
}
if(theChild!=null)
{
handled = theChild.onTouchEvent(event);
}
if(!handled) handled = super.onTouchEvent(event);
return handled;
}