Reputation: 1945
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())
}
Upvotes: 3
Views: 2143
Reputation: 1385
Do this
fun test(view: View){
Log.e("Click","Yes")
}
This will work.
Upvotes: 2