I want to add a style to themes.xml so that the style changes when I click the button in the kotlin file. My code doesn't work normally, and an error occurs.
This is my code.
themes.xml
<style name="borderButton" parent="Widget.MaterialComponents.Button.TextButton"/>
<style name="borderlessButton" parent="Widget.MaterialComponents.Button.OutlinedButton"/>
Fragment.kt
binding.btnWon.setOnClickListener {
binding.btnFore.setBackgroundResource(R.style.borderlessButton)
binding.btnWon.setBackgroundResource(R.style.borderButton)
}
binding.btnFore.setOnClickListener {
binding.btnWon.setBackgroundResource(R.style.borderlessButton)
binding.btnFore.setBackgroundResource(R.style.borderButton)
}
The style resource used in the kotlin code is accessible, but the "android.content.res.res.Resources$NotFoundException: Resource ID #0x7f140455" occurs in that area.
How can we solve this? Please provide a solution. Thanks!