Code example for Fragment

Methods: getActivity

0
    public void onClick(View v) {
        showToast(); 
    } 
 
    private void showToast() { 
        Toast.makeText(getActivity(), FRAGMENT_TOAST_MESSAGE, Toast.LENGTH_SHORT).show();
    } 
} 
Connect your IDE to all the code out there  Get Codota for Java