activity_main.xml
The way XML onClick is implemented is directed to Activities, not Fragments. The activity should own the btnClick1
method, not a fragment.
Since others have addressed setting onClick listener, let me add that if you have done so, and still getting the error check permissions required. For my case, the item on fragment was meant to open chat which requires microphone so it was not working until I added appropriate permissions in Manifest file.
You need to assign OnClickListener in fragment code to make it work. See Snicolas answer for the "why".