I have a Game class which contains an Array of ParseUsers with the key "players":
@ParseClassName(Game.GAME)
public class Game extends ParseObject {
public static final String PLAYERS = "players";
public void addPlayer(ParseUser player) {
addUnique(PLAYERS, player);
}
public List<ParseUser> getPlayers() {
return getList(PLAYERS);
}
}
The players have had a name field populated as follows:
ParseUser.getCurrentUser().put("name", name);
I want to get the names of these players and populate a ListView. I am trying to figure out how to use ParseQueryAdapter to do this, but I can't figure out anything that either lets you do a ParseQuery that will select ParseUsers found in an array on Game or a way to turn a ParseQuery into a query of ParseUsers based on that array. This is my best shot but I don't know how to select only the children of this query:
ListView playerListView = (ListView) findViewById(R.id.player_list);
ParseQueryAdapter<ParseUser> adapter = new ParseQueryAdapter<ParseUser>(this,
new ParseQueryAdapter.QueryFactory<ParseUser>() {
public ParseQuery create() {
ParseQuery query = game.getQuery();
query.include(Game.PLAYERS);
return query;
}
});
adapter.setTextKey("name");
playerListView.setAdapter(adapter);
Aucun commentaire:
Enregistrer un commentaire