In the Android API Guides for checkboxes, they state that you can set an attribute in a layout’s XML (android:onClick) to launch a designated method. The same is said in the guide for Buttons, but the guide for buttons also has this bit:
You can also declare the click event handler pragmatically rather than in an XML layout. This might be necessary if you instantiate the
Buttonat runtime or you need to declare the click behavior in aFragmentsubclass.
This raises the following question: Can you or can you not take advantage of the android:onClick attribute if the button or checkbox is found in a Fragment? If so, I would assume the method to be called would be declared in the Fragment, correct?
You can utilize the
onClickattribute in fragments. However, since aFragmentis part of anActivity, the designated method will be launched in the Activity class, not in the fragment.