android - Data of ListView keeps changing on scroll -
data of listview keeps changing on scrolling listview , down. seems wrong adapter. below code have used adapter. have 2 buttons in listview item, accept , reject request.if request either accepted or rejected 1 button appear.if request pending i.e p, both buttons displayed
public view getview(int position, view convertview_, viewgroup parent) { // todo auto-generated method stub viewholder view ; system.out.println("getview " + position + " " + convertview_); if (convertview_ == null) { convertview_ = inflator.inflate(r.layout.received_list_row, null); view = new viewholder(); view.imageviewpage = (imageview) convertview_ .findviewbyid(r.id.received_postimage); view.postimagebg = (imageview) convertview_ .findviewbyid(r.id.received_postimagebg); view.txt_post_title = (ctextview) convertview_ .findviewbyid(r.id.received_txt_post_title); view.txt_post_date = (ctextview) convertview_ .findviewbyid(r.id.received_txt_post_date); view.txt_post_time = (ctextview) convertview_ .findviewbyid(r.id.received_txt_post_time); view.llparent = (linearlayout) convertview_ .findviewbyid(r.id.received_llparent); view.llaccrej_btns = (linearlayout) convertview_ .findviewbyid(r.id.ll_accrejbtns); view.txt_acceptreq = (ctextview) convertview_ .findviewbyid(r.id.textview_acceptreq); view.invisible_txtbtn = (ctextview) convertview_ .findviewbyid(r.id.invisible_btn); view.txt_rejectreq = (ctextview) convertview_ .findviewbyid(r.id.textview_rejectreq); convertview_.settag(view); } else { view = (viewholder) convertview_.gettag(); } view.txt_post_title.settext(list.get(position).getactivity_name()); view.txt_post_date.settext(list.get(position).getactivity_postdate()); view.txt_post_date.settext(list.get(position).getactivity_postdate()); view.txt_post_time.settext(list .get(position) .getactivity_posttime() .substring( 0, list.get(position).getactivity_posttime() .lastindexof(":"))); if(request_status.equals("p")) { } else if (request_status.equals("a") && view.txt_acceptreq.gettag().equals(position)) { linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.match_parent); params.weight = 1.0f; view.txt_rejectreq.setvisibility(view.gone); view.txt_rejectreq.setclickable(false); view.invisible_txtbtn.setvisibility(view.gone); view.txt_acceptreq.settext("accepted"); view.txt_acceptreq.setclickable(false); view.txt_acceptreq.setgravity(gravity.center); view.txt_acceptreq.setlayoutparams(params); } else if (request_status.equals("r") && view.txt_rejectreq.gettag().equals(position)) { linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.match_parent); params.weight = 1.0f; view.txt_acceptreq.setvisibility(view.gone); view.txt_acceptreq.setclickable(false); view.invisible_txtbtn.setvisibility(view.gone); view.txt_rejectreq.settext("rejected"); view.txt_rejectreq.setclickable(false); view.txt_rejectreq.setgravity(gravity.center); view.txt_rejectreq.setlayoutparams(params); } view.txt_acceptreq.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub system.out.println("clicked accepted" + position); linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.match_parent); params.weight = 1.0f; view.txt_acceptreq.settext("accepted"); view.txt_acceptreq.setclickable(false); view.txt_acceptreq.setgravity(gravity.center); view.txt_acceptreq.setlayoutparams(params); view.txt_rejectreq.setvisibility(view.gone); view.txt_rejectreq.setclickable(false); view.invisible_txtbtn.setvisibility(view.gone); int user_id = list.get(position).getuser_id(); int activity_id = list.get(position).getactivity_id(); string status = "a"; macc_rejrequesttask = new acceptrejectactivityrequesttask( maccept_rejrequestresponder, activity); asyncutil.execute(macc_rejrequesttask, "" + user_id, "" + activity_id, status); } }); view.txt_rejectreq.setonclicklistener(new view.onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub system.out.println("clicked rejected " + position); linearlayout.layoutparams params = new linearlayout.layoutparams( layoutparams.wrap_content, layoutparams.match_parent); params.weight = 1.0f; view.txt_rejectreq.settext("rejected"); view.txt_rejectreq.setclickable(false); view.txt_rejectreq.setgravity(gravity.center); view.txt_rejectreq.setlayoutparams(params); view.txt_acceptreq.setvisibility(view.gone); view.txt_acceptreq.setclickable(false); view.invisible_txtbtn.setvisibility(view.gone); int user_id = list.get(position).getuser_id(); int activity_id = list.get(position).getactivity_id(); string status = "r"; macc_rejrequesttask = new acceptrejectactivityrequesttask( maccept_rejrequestresponder, activity); asyncutil.execute(macc_rejrequesttask, "" + user_id, "" + activity_id, status); } }); return convertview_; }
Comments
Post a Comment