1

I want to make SNS android application. Posts that users have posted and relations("Likes") are loaded from my Parse.com server. I succeeded in loading posts using parseQueryAdapter and ListView in a Fragment. But relation ("Likes") query loading event can not be loaded.

Manuel
  • 14,274
  • 6
  • 57
  • 130

2 Answers2

0

By default ParseQuery will not fetch relationship objects. You need to include relationship objects in ParseQuery.

ParseQuery<Post> postQuery= new ParseQuery<Post>("Post");
postQuery.include("likes");
Rutvij Shah
  • 113
  • 4
  • 10
0
ParseQueryAdapter<Post> mainAdapter;
ParseQueryAdapter.QueryFactory<Post> factory;
factory = new ParseQueryAdapter.QueryFactory<Post>() {
        @Override
        public ParseQuery<Post> create() {
            ParseQuery query = new ParseQuery("Post");
            query.whereEqualTo("Post_Liked", true);
            return query;
        }
    };
mainAdapter = new ParseQueryAdapter<Post>(this, factory) {
@Override
public View getItemView(final Post object, View v, ViewGroup parent) {
    if (v == null) {
        v = View.inflate(getContext(), R.layout.your_list_view, null);
    }
    return v;
}};

So why don't you just make it so that the user can set a post to "liked" or "not liked" with true and false respectively?

dave
  • 575
  • 4
  • 19
  • hmm... I think this way is for only one user. When each user is loading posts, bacause each of users have different liking posts, boolean column is different for them.. if I perform getRelation() and change the boolean column and Totally load posts with ParseQuery , I have to use many requests at Parse.com... – Jun Seok Kim Mar 24 '15 at 10:28