Android Custom Listview, Cannot change element in a single row -
i'm creating facebook custom listview feed using volley.
the listview on fragment , i'm using customlistadapter.java , searchitem.java classes load content listview.
the problem when click button or save button in row, changes liked , saved not in row in other rows.
in fragment
final viewholder holder = new viewholder(); @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view v = inflater.inflate(r.layout.newsfeed_popular_frag, container, false); listview = (listview) v.findviewbyid(r.id.popular_list); adapter = new customlistadapter(getactivity(), popularlist); listview.setadapter(adapter); listview.setonitemclicklistener(this);
in onitemclick of fragment
holder.likes_layout = (linearlayout) parent.findviewbyid(r.id.likes_layout); holder.saves_layout = (linearlayout) parent.findviewbyid(r.id.saves_layout); holder.likes_layout.setonclicklistener(new onclicklistener() { public void onclick(view v) { put_like(); } });
in customlistadapter
public view getview(int position, view convertview, viewgroup parent) { //post_id,name,user_prof_pic,post_description,post_datetime if (inflater == null) inflater = (layoutinflater) activity .getsystemservice(context.layout_inflater_service); if (imageloader == null) imageloader = appcontroller.getinstance().getimageloader(); if (convertview == null){ convertview = inflater.inflate(r.layout.newsfeed_list_row, null); holder = new viewholder(); holder.comment_layout = (linearlayout) parent.findviewbyid(r.id.comment_layout); holder.likes_layout = (linearlayout) parent.findviewbyid(r.id.likes_layout); holder.saves_layout = (linearlayout) parent.findviewbyid(r.id.saves_layout); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); }
please provide more detail of code proper answer. can see here ..
holder.likes_layout.setonclicklistener(new onclicklistener() {
public void onclick(view v) {
put_like(); } });
you not storing user state in code.so can suggest use bean class this
Comments
Post a Comment