Hi,
I've created my own compound widget, something just like this:
<LinearLayout>
<TextView />
<Button />
</LinearLayout>
I'm putting 15 of these in a ScrollView. I want it to behave similar to a ListView (I cannot use a ListView directly for this task).
I need the each widget to highlight when pressed. I've gotten this to work, but it's too sensitive - as soon as my finger hits the layout, it highlights - I'd like there to be a delay before highlight to discern between a real tap, and just a scroll gesture.
For example, in ListView, when you drag your finger to scroll, the row items don't get highlighted unless you leave your finger on the row for a second.
This is how I've set the background of each of my compound items:
private void setBg() {
ColorDrawable blr = new ColorDrawable(0xFFFFFFFF);
Drawable pressed = getContext().getResources().getDrawable(android.R.drawable.list_selector_background);
StateListDrawable bg = new StateListDrawable();
bg.addState(View.PRESSED_ENABLED_STATE_SET, pressed);
bg.addState(View.FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, pressed);
bg.addState(View.PRESSED_ENABLED_FOCUSED_STATE_SET, pressed);
bg.addState(View.ENABLED_WINDOW_FOCUSED_STATE_SET, pressed);
bg.addState(View.ENABLED_STATE_SET, blr);
bg.addState(View.SELECTED_WINDOW_FOCUSED_STATE_SET, blr);
setBackgroundDrawable(bg);
}
so I'm not sure if I just have set one of the above background drawable states incorrectly - or does ListView do some sort of touch handling internally for that tap delay?
Thanks