Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method has incorrect signature

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);

}
like image 933
Potatosaurus Avatar asked Mar 16 '16 20:03

Potatosaurus


1 Answers

Clean your project and then make sure the method onButtonHomeClick() is declared as public void.

like image 77
Lazaros Papadopoulos Avatar answered Sep 30 '22 04:09

Lazaros Papadopoulos