1

假设我有一个ParseQueryAdapter, 获得头衔。我想将这些标题存储到String[] blah = {}. 我怎样才能做到这一点?

我为什么要这样做?因为假设我有一个listView, 并且在该列表视图中我有多个内容,例如图片和 2 个文本视图。这 2 个 textViews 来自 Title 和 Description。所以,我几乎想要多个字符串。所以它将与以下内容相同:

String[] blah = {
"blah1"
"blah2"
"blah3"
}

但相反,我想要:

String[] blah = {
ParseQueryAdapter<ParseObject> query = new 
ParseQueryAdapter(this,"Class");
query.setTextKey("title");
    }
4

1 回答 1

1

做一个常规ParseQuery,并存储这些对象和一个List<String>

List<String> myObjects = new ArrayList<>();

public void runQuery() {
    ParseQuery<ParseObject> query = ParseQuery.getQuery("BarbecueSauce");
    query.whereStartsWith("name", "Big Daddy's");
    query.findInBackground(new FindCallback<ParseObject>() {
          @Override
          public void done(List<ParseObject> objects, ParseException e) {
             if(e == null){
               for(ParseObject o : objects){
                 myObjects.add(o.toString());
               }
             } else {
               Log.e(TAG, "Error: " + e.getMessage);
             }
         }
   }
}

public List<String> getObjects(){
   return myObjects;
}
于 2015-12-10T18:52:07.760 回答