I want to set a reminder at 12 p.m daily when the user on the switch. On isChecked()
I have setText
as "Remind at 12:00 PM". I want to set an alarm or reminder there. The code is as follows :
private RadioButton radioButtonPlayback, radioButtonTranslate;
private TextView switchStatus;
private Switch mySwitch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
switchStatus = (TextView) findViewById(R.id.switchStatus);
mySwitch = (Switch) findViewById(R.id.mySwitch);
//set the switch to ON
mySwitch.setChecked(true);
//attach a listener to check for changes in state
mySwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
switchStatus.setText("Remind at: 12:00 PM");
} else {
switchStatus.setText("No reminders set");
}
}
});
//check the current state before we display the screen
if (mySwitch.isChecked()) {
switchStatus.setText("Remind at: 12:00 PM");
} else {
switchStatus.setText("No reminders set");
}