Edit EditText from RecyclerView from outside (from the RecyclerView)

0

Could someone give me some solution or guide me with this:

I am implementing a RecyclerView (with a LinearLayoutManager) that shows a list with two, three or four EditText, in each row, according to the DataSet that it loads (it can only be one of the three options in each load).

All EditText are disabled (they do not allow entering text) from the ViewHolder.

But I can not get, through ToggleButton's (outside the RecyclerView), to enable / disable the EditText's of the columns of the RecyclerView. It's a button

EditText are created in an array of EditText's in the ViewHolder to later access their setEnable according to an array index (as if they were columns).

The closest I got to it was using a static Adapter method to enable / disable the EditText. The method called it from an Activity using also the notifyItemRangeChanged () of the Adapter, but that method can only be used once if an Object payload is not given as parameter. And until then I arrived, I did not investigate anymore because it has taken me a long time.

Does anyone know the correct way to achieve this? (manage to modify, from outside the RecyclerView, the properties of the View that it loads). Or guide me on what to try.

    
asked by felipe 08.01.2018 в 05:02
source

1 answer

2

Finally I solved the problem by re-establishing the Adapter in the RecyclerView. I did not use notifyItemRangeChanged () or another method.

What I did to modify the isEnable probiedad of my EditText's was to establish, in the Adapter, static public Boolean variables for each column (of EditText's) and a static public method to modify them from outside the Adapter. I use the Boolean variables to set the true or false for the EditText's isEnable's in the Adapter's ViewHolder constructor. Then, when I use the method from outside the Adapter, I also re-set the adapter (recyclerView.setAdapter (adapter)) so that the changes in EditText's are correctly made.

    
answered by 12.01.2018 в 03:48