我正在尝试检索“高分”列。我想在我的Android应用程序中的排行榜活动的列表视图中显示其所有值。活动开始但列表视图为空白。
public class LeaderboardsList extends AppCompatActivity {
ArrayList<String> highscores;
ArrayAdapter arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_leaderboards_list);
highscores = new ArrayList<String>();
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, highscores);
final ListView leaderboardList = (ListView) findViewById(R.id.listView);
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.addAscendingOrder("highscore");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> objects, ParseException e) {
if(e == null){
if(objects.size() > 0){
for(ParseObject object: objects){
highscores.add(String.valueOf(object.getNumber("highscore")));
}
leaderboardList.setAdapter(arrayAdapter);
}
}
}
});
}
}