0

This is doing my head in. I got this working in iOS in about 10 mins. Clearly I'm missing something. I'm simply trying to pull data out of parse.com into a textfield. I have found lots of examples but none explaining why it's not working correctly. Below is the code pulled from parse.com site and jiggyed with. Incidentally it's wigging out on totemList.getString particularly the "getString" part.

 ParseQuery<ParseObject> query = ParseQuery.getQuery("Birds");
           query.whereEqualTo("totemName", "Pigeon");
           query.findInBackground(new FindCallback<ParseObject>() {
               public void done(List<ParseObject> totemList, ParseException e) {
                   if (e == null) {
                       Log.d("score", "Retrieved " + totemList.size() + " scores");
                       String totemDesc = totemList.getString("totemDesc");
                       //Get the Totems Description
                       TotemDescription = (TextView)findViewById(R.id.animalDesc);
                       TotemDescription.setText(totemDesc);
                   } else {
                       Log.d("score", "Error: " + e.getMessage());
                       // something went wrong
                       TotemDescription = (TextView)findViewById(R.id.animalDesc);
                       TotemDescription.setText("not bob");
                   }
               }
           });
4

1 回答 1

3

List<>没有 getString() 方法。

List<ParseObject> totemList

也许您想要做的是遍历您的 ParseObject 列表以获取所有描述:

String descriptions = null;
for (ParseObject totem : totemList) {
    if (descriptions == null) {
        descriptions = totem.getString("totemDesc");
    } else {
        descriptions = descriptions + ", " + totem.getString("totemDesc");
    }
} 

类似的东西。然后将结果字符串设置为文本字段的文本

TotemDescription.setText(descriptions); 

如果您的 List<> 中有多个 ParseObject,您的文本将类似于:

Pigeon Totem, Another Pigeon Totem
于 2013-08-08T06:06:22.603 回答