gpt4 book ai didi

Android - Parse.com 检索查询的整个对象并显示在 ArrayList 中

转载 作者:太空狗 更新时间:2023-10-29 15:11:38 27 4
gpt4 key购买 nike

在下面的代码中,我在 HighScore 类中搜索按升序排列的最佳时间结果。所以我得到了最好的结果列表。我遇到的困难是将每次结果的名称和学校名称添加到列表中。(请参阅附图)

private class RemoteDataTask extends AsyncTask<Void, Void, Void> {
// Override this method to do custom remote calls
protected Void doInBackground(Void... params) {
// Gets the current list of bestTime in sorted order
ParseQuery query = new ParseQuery("TestsTopRecords");
query.orderByAscending("bestTime");

try {
results = query.find();
} catch (ParseException e) {

}
return null;
}

@Override
protected void onPreExecute() {
HighScoreTable.this.progressDialog = ProgressDialog.show(HighScoreTable.this, "",
"Loading...", true);
super.onPreExecute();
}

@Override
protected void onProgressUpdate(Void... values) {

super.onProgressUpdate(values);
}

@Override
protected void onPostExecute(Void result) {
// Put the list of results into the list view
ArrayAdapter<Double> adapter = new ArrayAdapter<Double>(HighScoreTable.this,R.layout.todo_row);
for (ParseObject object : results) {
adapter.add((Double) object.get("bestTime"));
}
setListAdapter(adapter);
HighScoreTable.this.progressDialog.dismiss();
TextView empty = (TextView) findViewById(android.R.id.empty);
empty.setVisibility(View.VISIBLE);
}
}

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_high_score_table);

TextView empty = (TextView) findViewById(android.R.id.empty);
empty.setVisibility(View.INVISIBLE);

new RemoteDataTask().execute();
registerForContextMenu(getListView());
}

How I would like it to look like

ScreenShot of the Prase.com DataBase

最佳答案

这可能是最简单的技巧。

使用 String 而不是 Double 并执行此操作

ArrayAdapter<String> adapter = new ArrayAdapter<String>(HighScoreTable.this,R.layout.todo_row);
for (ParseObject object : results) {
adapter.add((Double) object.get("bestTime") + " " + object.getString("Name") + " " + object.getString("SchoolAndCity"));
}

关于Android - Parse.com 检索查询的整个对象并显示在 ArrayList 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16018315/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com