-1

I am a beginner android developer and I have a question. I want to call a function when I check the checkbox. The checkbox is not on the activity_main.xml or other layout files the checkbox is in preferences.xml inside the xml folder so I want to call a function when the checkbox is checked inside the settings menu or preferences.xml.
Please help me!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
IMdevs
  • 1
  • 2
    Can you post what you've tried? There are different ways to go about it but it sounds like you might be able to get away with a listener for shared preference changes. See https://stackoverflow.com/questions/13596250/how-to-listen-for-preference-changes-within-a-preferencefragment – geco17 Apr 15 '18 at 16:55

1 Answers1

0
public void onCheckboxClicked(View view) {
    // Is the view now checked?
    boolean checked = ((CheckBox) view).isChecked();
            if (checked)
                // Do some action
            else
                // Do some action
            break;
    }
}

Hope this helps. Good luck.

amk
  • 70
  • 7