Android - Paged ListActivity that pages on horizontal swipe

1k views Asked by At

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?

1

There are 1 answers

0
Robert Nekic On BEST ANSWER

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