Android onClick method is not invoked

view story

http://stackoverflow.com – I add the onclick method to my button in the fragment2.xml <Button android:id="@+id/getTextButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Kliknij do fragment 1" android:onClick="onClick" /> Then defined this method in Fragment2.java public void onClick(View view){} But when I click on it the app crashes? What is wrong full XML and java file below package com.example.fragments; import android.app.Fragment; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater (HowTos)