2016-03-30 12 views
0

私は、ユーザーの検索と結果を入力するためのリストビューを持っています。結果には「友達を追加」ボタンがあります。AndroidパースどのようにしてgetObjectId()を使用できますか? ParseUserオブジェクトを設定するとき?

これは私がonClickのために持っているものです。

OnClickListener addRequest = new OnClickListener() { 
    @Override 
    public void onClick(View v) { 

     userConnection = new UserConnection(); 
     userConnection.setCurrentUser(User.getCurrentUser()); 
     userConnection.setOtherUser(users.get(position).getObjectId()); ////HELP, this is where I need to get the objectId for the user and set it as OtherUser 
     userConnection.setFriendRequestStatus(appConstants.FRIENDREQUESTSTATUS.PENDING); 
     userConnection.setCurrentUserSentRequest(true); 
     Utils.showOKdialog(context, "Press OK to send friend request"); 
     userConnection.saveInBackground(); 

     Log.d(TAG, "You have sent a friend request to " + userConnection.getOtherUser().getLastName() + " " + userConnection.getOtherUser().getFirstName()); 

    } 
}; 

私は私が助ける必要がある行にコメントを持って、私が午前問題は.getObjectIdがStringを返し、.setOtheruserがParseUserを求めています。 objectIdを取得する方法に関するアイデアは、リストビューの位置にあるユーザーのStringです。

私もこれを試してみましたが、それは.getParseUser(「OBJECTID」)の場合はnull参照して戻ってきた

userConnection.setOtherUser(users.get(position).getParseUser("objectId")); 

答えて

0

まあ、私はいつものように物事があまりにも複雑作っていた、それを考え出しました。解決策はただです

userConnection.setOtherUser(users.get(position)); 
関連する問題