Despite having the method onButtonHomeClick declared in the Java file MainActivity, when I attempt to reference the method in the XML I receive the error message: "Method onButtonHomeClick in MainActivity has incorrect signature". Both of them are below, and I cannot for the life of me figure out why it is returning such an error, especially since attempting to navigate to the declaration by Ctrl clicking onButtonHomeClick in the XML file navigates to the method in the Java class.
And it's definitely struggling to find the method, as the Android Monitor returns a fatal error when attempting to assign the behaviour to the button.
<!-- XML file -->
<item
android:id="@+id/button_home"
android:orderInCategory="100"
android:icon="@drawable/home"
android:title="Home"
android:onClick="onButtonHomeClick"
app:showAsAction="always"
/>
//Java method
public void onButtonHomeClick(View v){
Intent intent = new Intent(this, MainActivity.class);
}
Clean your project and then make sure the method onButtonHomeClick() is declared as public void
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With