简体   繁体   中英

retrieve all users from parse - android

I have a registered app on Parse with a signup/login system. Now I want to create an activity which grabs all the available users in the app and to display them one-by-one as a listview. Can someone tell me how can I do that?

Once you've setup your ListView 's adapter you can call this whenever you need to update it's contents:

public void updateUsers() {
    ParseQuery<ParseUser> query = ParseUser.getQuery();
    query.findInBackground(new FindCallback<ParseUser>() {
        @Override
        public void done(List<ParseUser> userObjects, ParseException error) {
            if (userObjects != null) {
                mUserAdapter.clear();
                for (int i = 0; i < userObjects.size(); i++) {
                    mUserAdapter.add(userObjects.get(i));
                }
            }
        }
    });
}    

That updates my adapter which is plugged into my ListView . If you have more than 100 users you want to return you'll need to up the limit as I hear that's the default (then you have to page the results, not sure how yet)

Side note: As far as I know you can't Subclass the ParseUser at the moment (you can, but you then can't use that as the object you're querying with using ParseUser.getQuery() (Which would normally be done by ParseUser.getQuery(MyCustomUserClass.class) if you were to query a customised object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM