Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio XML error "Corresponding method handler not found" on onClick

Why do I get error "Corresponding method handler not found" on the XML onClick line, after naming the onClick in XML and calling it on 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())
}
like image 931
J Adonai Dagdag Avatar asked Sep 03 '26 06:09

J Adonai Dagdag


1 Answers

Do this

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

This will work.

like image 141
Ankit Khare Avatar answered Sep 04 '26 20:09

Ankit Khare