如何为按钮添加滑动功能?

时间:2023-01-19 16:20:55

I want to show a button in a view.. If I swipe it left/right, I want to be able to get the next button.. How can I do it? Each button represents an option of a menu..

我想在视图中显示一个按钮..如果我向左/向右滑动,我希望能够获得下一个按钮..我该怎么办?每个按钮代表一个菜单选项..

Swiping should only work on the button.

滑动应仅适用于按钮。

1 个解决方案

#1


0  

The ViewPager class allows you to implement horizontal swiping through menu items. It can be set up to work on just on a small area of your Activity. You would use a fragment containing just a button in your case.

ViewPager类允许您通过菜单项实现水平滑动。它可以设置为仅在您的Activity的一小块区域上工作。您将使用仅包含一个按钮的片段。

Take a look at this post on the Android Developers Blog for an example.

在Android开发者博客上查看此帖子的示例。

#1


0  

The ViewPager class allows you to implement horizontal swiping through menu items. It can be set up to work on just on a small area of your Activity. You would use a fragment containing just a button in your case.

ViewPager类允许您通过菜单项实现水平滑动。它可以设置为仅在您的Activity的一小块区域上工作。您将使用仅包含一个按钮的片段。

Take a look at this post on the Android Developers Blog for an example.

在Android开发者博客上查看此帖子的示例。