I have a navigation drawer Android project that has several fragments. Inside one of the fragment layouts, I have a toggle switch. I have this simple handler stub inside of the fragment activity:
public void onCellDataSettingClicked(View view) {
boolean on = ((Switch) view).isChecked();
if (on) {
// Enable vibrate
} else {
// Disable vibrate
}
}
The problem is that when I get to this line "boolean on = ((Switch) view).isChecked();" the program crashes. I am unable to access the Switch from my fragment activity. If I place the same code inside of my main activity, everything works.
How do I get my handler to work inside of the associated fragment's activity and not just the main activity?