0
我在嘗試將解析查詢的結果應用於列表適配器時出現錯誤。我想將分析查詢的結果分配給Android上的我的列表適配器。我無法在回調之外分配結果,因爲查詢是findInBackground,結果不會及時返回。以下是我正在使用的代碼:Android ListAdapter不能應用於解析FindCallback
private void setupList() {
ListView listView = (ListView) findViewById(R.id.list_view);
Log.i("Setup List", ParseUser.getCurrentUser().getObjectId());
// Get the number of children the user has...
ParseQuery<ParseObject> query = ParseQuery.getQuery("Children");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null){
Log.i("Find All", "Retrieved: " + list.size());
if (list.size()>0){
numChildren = list.size();
adapter = new ListAdapter(this, createList(numChildren));
listView.setAdapter(adapter);
}
Log.i("Find All", "Success!");
}
else {
Log.i("Find All", "Failed!");
}
}
});
//Log.i("About to call the list", "Retrieved");
//adapter = new ListAdapter(this, createList(numChildren));
//listView.setAdapter(adapter);
}
你有沒有崩潰? – hoomi
不,我收到警告。 Android不喜歡在回調中使用「this」。我正在考慮在解析上下文之外使用上下文,但我不確定要使用什麼。 –
錯誤消息是:錯誤:(97,51)錯誤:不兼容的類型:>無法轉換爲上下文 –