android - What method is called when a view is scrolled out of view in ListView? -
so have listview
made custom adapter using layout textview
, edittext
.
for edittext
use list<string>
store content of edittexts in list. using onfocuschangelistener(
).
the problem i'm having when edittext
focused , scroll enough it's view recycled, loose content of it, if click away becomes unfocused before scrolling out of visible area works fine.
i thinking of saving content of when recycled, or destroyed, why i'm asking method called when scrolled out of visible area. or can when list starts scrolling, if there method can use this.
here getview
method custom adapter:
public view getview(final int position, view convertview, viewgroup parent) { final viewholder holder; if(convertview == null) { holder = new viewholder(); convertview = inflater.inflate(r.layout.list_item_edit_content, null); holder.input = (edittext) convertview.findviewbyid(r.id.input); holder.title = (textview) convertview.findviewbyid(r.id.rowname); convertview.settag(holder); } else { holder = (viewholder) convertview.gettag(); } holder.title.settext(columnnames.get(position)); holder.input.settext(values.get(position)); holder.input.setonfocuschangelistener(new onfocuschangelistener() { @override public void onfocuschange(view v, boolean hasfocus) { if(!hasfocus) { values.set(position, holder.input.gettext().tostring()); } } }); return convertview; } private class viewholder { edittext input; textview title; }
you use other listener:
holder.input.addtextchangedlistener(new textwatcher(){ public void aftertextchanged(editable s) {} public void beforetextchanged(charsequence s, int start, int count, int after){} public void ontextchanged(charsequence s, int start, int before, int count){} });
Comments
Post a Comment