我想从parse.com获取一个列表并将其设置为我创建的微调器
我已经使用过这段代码,但它以这种格式返回微调器中的项目
com.parse.ParseObject@132610f4
final Spinner country = (Spinner) findViewById(R.id.schoolSelect);
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("school");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
ArrayAdapter adapter = new ArrayAdapter(
getApplicationContext(),android.R.layout.simple_list_item_1 ,list);
country.setAdapter(adapter);
} else {
}
}
});
有没有人知道如何只在查询中获取某个列,并让其中的数据显示出来 我希望得到它的内容的列称为
SchoolName
答案 0 :(得分:3)
只需创建另一个列表即可存储ParseObject
final Spinner country = (Spinner) findViewById(R.id.schoolSelect);
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("school");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> list, ParseException e) {
if (e == null) {
ArrayList<String> nameList = new ArrayList<>();
for(ParseObject object : list) {
nameList.add(object.getString("SchoolName"));
}
ArrayAdapter adapter = new ArrayAdapter(
getApplicationContext(),android.R.layout.simple_list_item_1 ,nameList);
country.setAdapter(adapter);
} else {
}
}
});