-1

I wanted to add a MaterialToggleButtonGroup using View Interop to the UI. It gave me an error while doing so.

My Code:

SimpleAndroidView(
        modifier = modifier,
        update = {
            it.check(it.getChildAt(selectedCount).id)
        }
    ) {
        val m = MaterialButtonToggleGroup(it).apply {
            isSingleSelection = true
        }
        items.forEachIndexed { index, s ->
            m.addView(
                MaterialButton(it).apply {
                    text = items[selectedCount]
                    setOnClickListener {
                        onSelectionChanged(index)
                    }
                }
            )
        }
        m
    }

Error:

FATAL EXCEPTION: main
                                                                                                    Process: {package name}, PID: 25491
                                                                                                    java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
                                                                                                        at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:247)

0 Answers0