Android Studio XML Error "No matching method handler found" on onClick

Why am I getting the error "No matching method handler found" on the onClick XML line after it calls onClick in the XML and calls it in the Main Activity?

Snippet from Activity_main.xml:

        <Button
            android:id="@+id/buPercentage"
            android:layout_width="30pt"
            android:layout_height="30pt"
            android:layout_weight="1"
            android:background="@color/lightgray"
            android:onClick="buPercentageEvent" //Error says Corresponding method handler not found
            android:text="%"
            android:textSize="18sp" />

      

Snippet from MainActivity.kt

fun buPercentageEvent()
{
    val convertToDecimal = displayText.text.toString()
    val newNumber = convertToDecimal.toDouble() / 100
    displayText.setText(newNumber.toString())
}

      

+3


source to share


1 answer


Do it

fun test(view: View){
        Log.e("Click","Yes")
    }

      



This will work.

+1


source







All Articles