Home > Mobile >  Monitoring, the Android recyclerview viewholder writes is lost to monitor events
Monitoring, the Android recyclerview viewholder writes is lost to monitor events

Time:01-29

I'm onCreateViewHolder set up event listeners,
When I click on the switch to receive the log, but click again won't accept it, then I click the button to receive other seat log, every click different buttons will be able to receive the log but click the same button will not be able to receive the log what reason is this?
But in onBindViewHolder set up event listeners will not appear this kind of problem,


Public DFViewholder (@ NonNull View itemView, int type, int position) {
Super (itemView, type, position);
DeviceName=itemView. The findViewById (R.i d.d evice_name);
Swip=itemView. The findViewById (R.i d.s wit);
Linear=itemView. The findViewById (R.i d.d evice_linear);
Swip. SetOnCheckedChangeListener (new CompoundButton. OnCheckedChangeListener () {
@ Override
Public void onCheckedChanged (CompoundButton buttonView, Boolean isChecked) {
The d (TAG, "the position=" + position);
}
});
}

CodePudding user response:

You may have a look, onCreateViewHolder and onBindViewHolder execution times are different, when the inside of the each adapter itemview change position, to hide will affect the above element has been endowed with the values of the key to study this problem is of great help to future, we often appear all values into a after the refresh, or click on the button to trigger the same click event,