Gallery 内的 ScrollView 内的按钮不响应单击

发布于 2024-11-30 07:18:39 字数 402 浏览 6 评论 0原文

我有一个以 ScrollViews 作为子项目的画廊。滚动视图可以在滚动区域内包含文本、图像和按钮。我需要确保触摸事件按预期正确处理。

我在这里找到了一个很好的解决方案: ScrollView inside Gallery,两者独立滚动

不幸的是,这个解决方案对按钮没有帮助。有时,点击按钮会导致图库控件滚动到相邻项目。

当按钮位于滚动视图内部且滚动视图是图库控件中的项目时,如何防止 ScrollView 和 Gallery 滚动,然后用户点击按钮?

有人可以为我提供识别“点击”手势的解决方案吗?

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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄傲 2024-12-07 07:18:39

我曾经遇到过类似的情况 - 我通过在 XML 中添加 onClick 来修复它:

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

然后在您的代码中添加:

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
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文