Android app crashing (fragment and xml onclick)

Activity:

If are having activity and if you define android:onClick attribute in XML then you just need to define a method with the same name in Activity.

Fragment:

But whenever you have Fragment and if you want to define click listener by just defining android:onClick attribute then you have to define a method with the same name in actual activity from where Fragment has been called.

OR you can simply implement a click listener programmatically.

Leave a Comment