vendredi 15 juillet 2022

Android Checkbox weird behavior (becomes disabled and clickable after bringing fragment from backstack)

I am currently facing an issue using CheckBox in my fragment. Once the fragment is opened, the checkbox works properly. The check box's behavior changes in two case:

  • When I bring the fragment from the backStack using Back button
  • When I open the fragment for the second time.

I t seems like when the fragment is reCreated, the checkBox becomes gray (disabled) and still clickable.

<androidx.appcompat.widget.AppCompatCheckBox
            android:id="@+id/checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            app:layout_constraintTop_toBottomOf="@id/ivLogo"
            app:layout_constraintStart_toStartOf="@id/guideStart"
            app:layout_constraintEnd_toEndOf="@id/guideEnd"/>

I tried to save its state but didn't work.

PS: After getting this behavior, (checkbox.isEnabled = true) doesn't work anymore.

Any help ?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire