I have a ListActivity; and for each item in the ListView there is a checkbox.
When you touch a list item, another Activity launches.
When you use the trackpad/trackball to highlight (read: select) an item and click the trackpad, it essentially simulates touching the item. This causes my other Activity to launch.
I would like clicking the trackpad to check the checkbox of the highlighted item. Is there a handler I can override to do this?
You need to override the onTrackballEvent(MotionEvent)
method and catch ACTION_DOWN
. Here is an example of how to do this:
@Override
public boolean onTrackballEvent(MotionEvent event) {
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
//Do your work here
return true;
}
return super.onTrackballEvent(event);
}
Hope this works for you!