Text change event inside listview in android -
i new android , have edittext inside listview want when user puts text or value edittext value should displayed textview inside same listitem.i tried done in getview of custom adapter not working me.my code this:
public view getview(int position, view convertview, viewgroup parent) { view view = convertview; if (view == null) { view = linflater.inflate(r.layout.list_style_task , parent, false); } litem p = getproduct(position); tvaquantity=((textview) view.findviewbyid(r.id.tvaquantity )) ; ((textview) view.findviewbyid(r.id.tvmaterial )).settext(p.getmname() ); ((textview) view.findviewbyid(r.id.tvtask )).settext(p.gettname() ); tvbquantity=((textview) view.findviewbyid(r.id.tvbquantity )) ; tvbquantity.settext(p.getbq()); etquantity=(edittext)view.findviewbyid(r.id.ettaskquantity); etquantity.addtextchangedlistener(new textwatcher() { @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void ontextchanged(charsequence s, int start, int before, int count) { if(integer.parseint(s.tostring())<=integer.parseint(tvbquantity.gettext().tostring())) { tvaquantity.settext(s.tostring()); } else { tvaquantity.settext(tvbquantity.gettext()); } } @override public void aftertextchanged(editable s) { } }); // checkbox cbbuy = (checkbox) view.findviewbyid(r.id.checkbox); //cbbuy.setoncheckedchangelistener(mycheckchanglist); // cbbuy.settag(position); // cbbuy.setchecked(p.selected); return view; }
need valuable suggestions.
2 alternatives are:
- you have update respected string model class displayed textview.
- you can call
notifydatasetchanged();
after settext() method in adapter.this refresh list view.
Comments
Post a Comment