Reputation: 86627
When I click a button, its method does not get called, but exception is thrown. Why?
Caused by: java.lang.NoSuchMethodException: myMethod [class android.view.View]
main.xml:
android:onClick="myMethod"
Activity:
public class MyActivity extends Activity {
//onCreate etc
public void myMethod() {
}
}
Upvotes: 0
Views: 76
Reputation: 40406
public void myMethod(View view) {
}
you forgot parameter View
of myMethod
And if you have no view then you can call method myMethod(null)
Upvotes: 5