Android - 水平滑动分页的分页列表活动

发布于 2024-10-19 17:41:30 字数 792 浏览 2 评论 0原文

我有一个实现 Runnable 的列表活动,以便我的数据获取是通过进度条完成的。数据是从网络服务中提取的。现在,我要获取所有用户,但我想更改它,以便它一次检索一页用户,而不是一次检索所有用户。

public class ActiveUsersActivity extends ProtectedListActivity implements Runnable {
    ProgressDialog progress;
    ArrayList<UserModel> users;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        progress = ProgressDialog.show(ActiveUsersActivity.this, "", "Loading...", true);

        Thread thread = new Thread(ActiveUsersActivity.this);
        thread.start();
    }

    @Override
    public void run() {
    //Get user data
    users = MyService.GetAllUsers();
    }
}

因此,我需要进行的修改是将运行更改为一次获取​​一页。这很容易,但我的问题在于如何进行实际的水平滑动。理想情况下,我想让列表向左或向右滑动,就像您滑动时主屏幕所做的那样。关于如何做到这一点有什么想法吗?

I have a list activity that implements Runnable so that my data fetch is done with a progress bar. The data is pulled from a web service. Right now, I go get all of the users, but I would like to change it so it retrieves the users one page at a time, instead of all at once.

public class ActiveUsersActivity extends ProtectedListActivity implements Runnable {
    ProgressDialog progress;
    ArrayList<UserModel> users;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        progress = ProgressDialog.show(ActiveUsersActivity.this, "", "Loading...", true);

        Thread thread = new Thread(ActiveUsersActivity.this);
        thread.start();
    }

    @Override
    public void run() {
    //Get user data
    users = MyService.GetAllUsers();
    }
}

So, the modifications I need to make are to change run to get one page at a time. That is easy enough, but my problem lies in how to do the actual horizontal swipe. Ideally, I would like to make the list slide left or right like the home screens do when you do a swipe. Any ideas on how to do this?

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

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

发布评论

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

评论(1

风吹雨成花 2024-10-26 17:41:30

至于滑动,您看过 GestureDetector 吗?查看 OnGestureListener 及其 onFling。

As for the swiping, have you looked at the GestureDetector? Check out the OnGestureListener and its onFling.

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