I have created a function called “onButtonClicked” and I don’t want to use a setOnClickListener because I am practicing with different views
the problem is when I create the onButtonClicked function, I see this warning
`(the “onButtonClicked” function is never used)
My code:
XML
<Button
android:id="@+id/bt301_tw"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:background="?android:attr/colorActivatedHighlight"
android:onClick="onButtonClicked"
android:text="@string/rodiogroup_301" />
Mainactivity
fun onButtonClicked(view: View) {
if (view.id == R.id.bt301_tw) {
val intent = Intent(this, MainActivity_04_ReadioGroup::class.java)
startActivity(intent)
}
}