Textwatcher.ontextchanged Called Multiple Times
I've read a few threads about this problem, but couldn't find a thorough answer. I have a ListView with 3 rows, each contains a TextView and an EditText, and a custom adapter that
Solution 1:
Problem is that the LisView elements are being recycled and therefore the old TextWatcher is still attached after recycling the row. Therefore every time getView is called a new TextWatcher is added while the old ones remain attached to the EditText. Unfortunately there is no function to remove all old TextWatchers attached, therefore the only solution is to create a custom EditText where you keep a reference to all TextWatcher and then create a custom function to remove them all when recycling the View in getView.
Solution 2:
Another solution is to check if the field (EditText or TextView) isDirty.
@OverridepublicvoidonTextChanged(CharSequence s, int start, int before, int count) {
if (mTextView.isDirty())
doWork();
}
Post a Comment for "Textwatcher.ontextchanged Called Multiple Times"