我是Parse.com和Android的新手,我正在努力从Parse对象中读取数据。我阅读了文档并下载了教程,但目前尚不清楚。我有一个名为Issue的ParseObject,我只需要从该对象读取数据并将其显示给用户。这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_issue);
Parse.enableLocalDatastore(this);
Parse.initialize(this, "QKpM7ar7aWwrbEeTcrSGJ5bDnLMCUtc1kCr26Enl", "MCBdIQ6Y0dTsIoahzJ44UfR1zHZPJMQPwiETwj47");
ParseQuery<ParseObject> query = ParseQuery.getQuery("Issue");
query.whereEqualTo("objectId", "2aRwvd1Rnv");
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> issueList, com.parse.ParseException e) {
if (e == null) {
Log.d("Issue", "Retrieved " + issueList.size() + " issue");
Toast.makeText(getApplicationContext(), "List" + issueList, Toast.LENGTH_LONG).show();
} else {
Log.d("score", "Error: " + e.getMessage());
}
}
});
}
我不明白如何从这个ParseObject中读取数据。返回的结果issueList是这样的:List [com.parse.ParseObject@4b079f88]
如果我使用issue.getString(&#34; objectId&#34;),我会收到错误消息。请帮忙。
答案 0 :(得分:0)
感谢Shubendara先生,我能解决这个问题:
if (issueList!=null){
if (issueList.size()>0){
for( int i = 0; i<issueList.size(); i++){
String o = issueList.get(i).getString("Title");
Toast.makeText(getApplicationContext(), "List" + o, Toast.LENGTH_LONG).show();
}
}