开发者

Buttons inside ScrollView inside Gallery don’t respond to click

I have a Gallery with ScrollViews as child items. Scroll view can contain text, images and button inside of the scroll area. I need to make sure that the touch events are handled correctly and as expected.

I’ve found solution开发者_JS百科 a good here: ScrollView inside Gallery, both scrolling independently

Unfortunately, this solution doesn't help with buttons. Tapping on the button, sometimes, causes gallery control to scroll to the neighbor item.

How to prevent ScrollView and Gallery from scrolling then user is tapping on the button when button is inside of the scroll view and scroll view is item in the gallery control?

Can someone provide me with a solution of recognizing “click” gesture?


I had something like this once - I fixed it by adding an onClick in the XML:

<button android:onClick="handleClick" ... />

then in your code:

public void handleClick(View view) {
    // get the position of the clicked item in the list
    int position = getListView().getPositionForView(view);
    // do something with the item
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜