1

Let's say I have a ParseQueryAdapter, getting titles. I want to store those titles into String[] blah = {}. How can I do that?

Why am I doing this? Because let's say I have a listView, and in that list view I have multiple stuff such as a picture, and 2 textViews. those 2 textViews are coming from Title and Description. So, pretty much I want multiple strings. So it would be the same as:

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

But instead I want:

String[] blah = {
ParseQueryAdapter<ParseObject> query = new 
ParseQueryAdapter(this,"Class");
query.setTextKey("title");
    }
Al Lelopath
  • 6,448
  • 13
  • 82
  • 139
AbAppletic
  • 23
  • 8
  • do you want to initialize the array with standard values? – Vasileios Pallas Dec 10 '15 at 18:35
  • @vspallas I edited the post. And sory I'm new to development so please explain more. Do you mean that I want to do as the first example in the question? If that's the case, then no. I want it like the second example, but of course, I get errors since I cannot apply that in `string[]{}` – AbAppletic Dec 10 '15 at 18:38

1 Answers1

1

Do a regular ParseQuery, and store those objects and a 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;
}
Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
  • No,no no. I am being specific here. In the `parseQueryAdapter`, I am getting a whole column. I cannot do that in a normal `ParseQuery`. Please read carefully next time. – AbAppletic Dec 11 '15 at 15:28
  • I have read carefully and I still stand by my answer. The parse adapter is only something to make things easier, but if you don't fully understand what you are doing you should stick with the parse query until you do. And, you do not get a "whole column". You get a list of objects matching that query. – Chad Bingham Dec 11 '15 at 15:52
  • Well, let's say my Parse Class name is Class, and I want to get all objects on column "Title", and add it to your example? – AbAppletic Dec 11 '15 at 16:28
  • Columns are not objects. So do you want to get any object that has "Title" specified? then use `whereExists("Title");` on your query. – Chad Bingham Dec 11 '15 at 16:47
  • Keep in mind each row is an object. When you query anything from parse, you query the entire row and all of its content (with the exception of ParseObject values). So if you are wanting to look at all of your "titles", you query all of your objects, throw them in a list, and display them by showing their title. – Chad Bingham Dec 11 '15 at 16:49
  • Ok. Thanks. That sums things up – AbAppletic Dec 11 '15 at 16:54