0

I have been able to retrieve strings and files in Parse. However, I have difficulty retrieving number from the number column. In particular, I want to retrieve number from Parse and cast it into a TextView that will display the number.

Below is the code I have to retrieve a string:

@Override
public void done(List<ParseUser> objects,ParseException e) {
    for(int i=0;i<objects.size();i++){
        // Do whatever you need to extract object from "users"
        ParseQuery<ParseObject> query = ParseQuery.getQuery("User");
        query.whereNotEqualTo("objectId", ParseUser.getCurrentUser()
                .getObjectId());
        // users with Gender = currentUser.Looking_Gender
        query.whereEqualTo("Gender", userLookingGender);
        // users with Looking_Gender = currentUser.Gende r
        query.whereEqualTo("Looking_Gender", userGender);
        query.setLimit(1);
        query.whereEqualTo("ActivityName", activityName);
        // query.whereGreaterThanOrEqualTo("Age", minimumAge);
        // query.whereLessThanOrEqualTo("Age", maximumAge);

        mUserAgeRetrieved = (TextView) getActivity().findViewById(R.id.userlistage);
        mUserAgeRetrieved.setText(objects.get(i).get("Age").toString()); 
    }//for loop
}

In particular, I would like the following line to be converted into a number instead of a string

mUserAgeRetrieved.setText(objects.get(i).get("Age").toString());

What do I have to do?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
code_legend
  • 3,547
  • 15
  • 51
  • 95
  • 1
    Why don't you use `Integer.parseInt()`? – Andrew T. Sep 02 '14 at 02:44
  • thanks for your suggestion. Were would I change to include Integer.parseInt() mUserAgeRetrieved.setText(objects.get(i).get("Age").toString()); – code_legend Sep 02 '14 at 09:18
  • 1
    Refer to [How to convert string to int in Java?](http://stackoverflow.com/questions/5585779/how-to-convert-string-to-int-in-java), but be careful when you call [`setText()` with `int`](http://stackoverflow.com/questions/3994315/integer-value-in-textview). – Andrew T. Sep 02 '14 at 09:28
  • thanks Andrew, how does int iage = Integer.parseInt("UserAge"); mUserAgeRetrieved.setText(iage); look? – code_legend Sep 02 '14 at 09:47

0 Answers0