java - Parse delete object from listview android -


i'm using parse on app send pushes other users has app. want user able remove added friend list. i've managed modify code, deletes first item on list. how can modify delete selected user?

                    @override                     public void onpositive(materialdialog dialog) {                         parsequery<parseobject> query = parsequery.getquery("friend");                         query.whereequalto("user", mcurrentuser);                         query.findinbackground(new findcallback<parseobject>() {                             @override                             public void done(list<parseobject> list, parseexception e) {                                 if (list.size() != 0)                                     log.v("tag", "sizzzze" + list.size());     //showing 1                                 list.get(0).deleteinbackground(new deletecallback() {                                     @override                                     public void done(parseexception e) {                                         if (e == null) {                                             toast.maketext(getbasecontext(), "deleted successfully!", toast.length_long).show();                                         } else {                                             toast.maketext(getbasecontext(), "cant delete tickle!" + e.tostring(), toast.length_long).show();                                         }                                      }                                 });                             }                         });                     } 

update: @haint

// listener listview item clicks private class friendlongclicklistener implements adapterview.onitemlongclicklistener {      @override     public boolean onitemlongclick(adapterview<?> parent, view view, int position, long id) {         final string friend = muserfriends.get(position).getstring("user");         new materialdialog.builder(mainactivity.this)                 .title("remove"+" "+muserfriends.get(position).getusername().touppercase() + "?")                 .content("do want remove" + " " + muserfriends.get(position).getusername().touppercase() + " " + "from friend list?")                 .positivetext(r.string.dialog_yes)                 .negativetext(r.string.dialog_no)                 .callback(new materialdialog.buttoncallback() {                     @override                     public void onpositive(materialdialog dialog) {                         parsequery<parseobject> query = parsequery.getquery("friend");                         query.whereequalto("user", mcurrentuser);                         query.findinbackground(new findcallback<parseobject>() {                             @override                             public void done(list<parseobject> list, parseexception e) {                                 if (list.size() != 0)                                     log.v("tag", "sizzzze" + list.size());     //showing 1                                 list.get(0).deleteinbackground(new deletecallback() {                                     @override                                     public void done(parseexception e) {                                         if (e == null) {                                             toast.maketext(getbasecontext(), "deleted successfully!", toast.length_long).show();                                         } else {                                             toast.maketext(getbasecontext(), "cant delete tickle!" + e.tostring(), toast.length_long).show();                                         }                                      }                                 });                             }                         });                     }                          @override                     public void onnegative(materialdialog dialog) {                     }                 })                 .show();         return true;     }  } 

query.whereequalto("user", mcurrentuser); 

change to

query.whereequalto("user", muserfriends.get(position)); 

or

query.whereequalto("user", friend); 

because don't know data type of adapter can assume cases.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -