Android - 水平滑动分页的分页列表活动
我有一个实现 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
至于滑动,您看过 GestureDetector 吗?查看 OnGestureListener 及其 onFling。
As for the swiping, have you looked at the GestureDetector? Check out the OnGestureListener and its onFling.