我希望在没有Object
的情况下获得Parse中something.put("blalala")...
的字符串。
仅从Parse获取字符串。我的代码出了什么问题?我怎么能这样做?
public class MyActivity extends Activity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
Parse.initialize(this, "blablablbalba", "blablablabla");
final ParseObject gameScore = new ParseObject("GameScore");
//txtv
textView = (TextView)findViewById(R.id.textView);
//txtv
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.getInBackground("theid", new GetCallback<ParseObject>() {
@Override
public void done(ParseObject parseObject, com.parse.ParseException e) {
if (e == null){
String playerName = gameScore.getString("playerName");
textView.setText(playerName);
}
else {
textView.setText("Mince !!!");
}
}
});
}
}
答案 0 :(得分:0)
代码应该是String playerName = parseObject.getString("playerName");
parseObject是保存查询结果的变量,而不是gameScore变量
(编辑:)直接来自文档:
ParseQuery<ParseObject> query = ParseQuery.getQuery("GameScore");
query.getInBackground("xWMyZ4YEGZ", new GetCallback<ParseObject>() {
public void done(ParseObject object, ParseException e) {
if (e == null) {
// object will be your game score
} else {
// something went wrong
}
}
});