[英]ParseQuery to retrieve string by objectId in Parse Database
I have created a class "Topics" in parse database and I'm able to retrieve it to textview.我在解析数据库中创建了一个“Topics”类,我可以将它检索到 textview。
I have more than one textView so I don't want to repeat the same code.我有多个 textView,所以我不想重复相同的代码。
How to retrieve a string for example if it's objectID is "fdjk"如何检索字符串,例如如果它的 objectID 是“fdjk”
for example I want it to work this way例如我希望它以这种方式工作
if(objectId == fdjk){
String subTopicName = arg0.getString("class_1");
textView.setText("" + subTopicName);
}
else if(objectId == fdjkk){
String subTopicName1 = arg0.getString("class_1");
textView1.setText("" + subTopicName1);
}
The following code works single object以下代码适用于单个对象
ParseQuery<ParseObject> query=ParseQuery.getQuery("Topics");
query.getInBackground("fRGt3oz8af", new GetCallback<ParseObject>(){
@Override
public void done(ParseObject arg0, ParseException arg1) {
if (arg1==null)
{
subTopicName = arg0.getString("class_1");
textView.setText("" + subTopicName);
progressDialog.dismiss();
}
else
{
Log.d("topic", "Error: " + arg1.getMessage());
}
}});
You can get the objectId via您可以通过获取 objectId
myParseObject.getObjectId()
Or maybe you should to a findInBackground so you can hace the full list of objects或者也许您应该使用 findInBackground 以便您可以获取完整的对象列表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.