Using a Compose view that inherent from AbstractComposeView inside an XML ui code of a fragment Knowing that this fragment is part of a navigation graph (Jetpack navigation) When i press the back button going back to my fragment, the compose view just disappeared. It's only drawing for the first time i open the fragment.
Bellow view code
class ProgressComposeView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AbstractComposeView(context, attrs, defStyleAttr) {
private var steps = mutableStateOf(0)
private var currentStep: Int = 0
private var windowWidth: Int = 0
@Composable
override fun Content() {
ProgressView(steps.value, currentStep, windowWidth)
}
fun setData(steps: Int, currentStep: Int, windowWidth: Int) {
this.steps.value = steps
this.currentStep = currentStep
this.windowWidth = windowWidth
}
}
@Composable
fun ProgressView(totalSteps: Int, currentStep: Int, windowWidth: Int) {
..... }
setContent
in theonViewCreated
method. – Lucky