我正在尝试从Parse.com中的ParseUser中删除一个实现。 我试图在互联网上找到如何做到这一点,但我没有成功。 这里有人可以帮帮我吗?还是给我一些线索?它似乎无法为我提供帮助。
我尝试了以下代码:
@Override
public void onDismiss(final AbsListView listView,
final int[] reverseSortedPositions) {
for (int position : reverseSortedPositions) {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.whereEqualTo("username", values.get(position));
query.findInBackground(new FindCallback<ParseUser>() {
public void done(List<ParseUser> objects, ParseException e) {
if (objects.size() != 0) {
if (objects.get(0).getUsername() != null) {
final ParseUser currentUser = ParseUser
.getCurrentUser();
if (currentUser != null) {
{
final ParseObject friend = new ParseObject(
"Friends");
friend.remove(values.get(position));
friend.deleteInBackground(new DeleteCallback() {
@Override
public void done(ParseException e) {
ParseRelation relation = currentUser
.getRelation("Friends");
relation.remove(friend);
Toast.makeText(getApplicationContext(),
"Player Has Been
Remove"+values.get(position),
Toast.LENGTH_SHORT).show();
currentUser.saveInBackground();
}
});
});
Toast.makeText(getApplicationContext(),
"Player Has Been Added",
Toast.LENGTH_SHORT).show();
}
}
//dialog.hide();
}
}
}
});
adapt.remove(values.get(position));
adapt.notifyDataSetChanged();
}
}
拜托,我需要你的帮助。 抱歉我的英语很差
答案 0 :(得分:0)
尝试将代码修改为此,我猜测将模板设置为ParseObject对于将关系链接到用户非常重要。
ParseRelation<ParseObject> relation = currentUser.getRelation("Friends");
relation.remove(friend);
Toast.makeText(getApplicationContext(), "Player Has Been Add2321434243ed",Toast.LENGTH_SHORT).show();
currentUser.saveInBackground();