Today the issue of RecyclerView recorded in item used in EditText

 

 

 

 

Today the issue of RecyclerView recorded in item used in EditText

When we use listening in item often encounter some problems, such as data input after the scroll was found in the EditText, the multiplexed data item in the confusion, we will use often add listeners to store data, so refreshing when he met problem. If you do not listen when you set content to be removed EditText will monitor the response code execution. Affect the data show.

Here it is when I'm doing such a demand, because it is a time to have to enter real-time monitor, I used onTextChanged, if you do not, you can use afterTextChanged. Here it is mainly about listening will respond when EditText setting content. It needs to be removed before setting the content to listen, and then set the contents, adding listeners.

onBindViewHolder中做如下操作
if(holder.et_num.getTag() instanceof  TextWatcher){
            holder.et_num.removeTextChangedListener((TextWatcher)holder.et_num.getTag());
        }

if(StringUtils.isEmpty(moneyUsingDetailItem.getNum())){
            holder.et_num.setText("");
        }else{
            holder.et_num.setText(moneyUsingDetailItem.getNum());
        }


TextWatcher numWatcher = new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

//内容操作
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        };
        holder.et_num.addTextChangedListener(numWatcher);
        holder.et_num.setTag(numWatcher);

 If the exchange of ideas welcome

 

 

 

Guess you like

Origin blog.csdn.net/chengzuidongfeng/article/details/85317399