USE CASE
I have a RecyclerView whose ViewHolder contains a TextInputLayout. For some situations I want it to display a hint and for other situations I don't.
ISSUE
When the RecyclerView recycles a ViewHolder that has previously displayed a hint but on the new bind does not require a hint. It will display an empty hint instead. See picture:
Image for NOT recycled ViewHolder
The problem seems to happen ONLY if the new binding has NO hint. If I set a hint to every ViewHolder with different values, it recycles and displays correctly.
Snippet
Adapter.kt
override fun onBindViewHolder(holder: FormViewHolder, position: Int) {
holder.onBind(getItem(position))
}
ViewHolder.kt
override fun onBind(model: Model) {
binding.inputLayout.isHintEnabled = model.hasHint
binding.inputLayout.isHintAnimationEnabled = model.hasHint
binding.inputLayout.hint = model.hintValue
}
I tried:
- Updating to latest version ATM:
com.google.android.material:material:1.8.0
TextInputLayoutclass changed a bit, apparently. Just FYI. Cheers!