Android : How to use setIs24HourView(boolean)?

on Friday, October 24, 2014


I have a problem here. I try to make a new alarm here.


I want to toggle TimePicker View mode between 12h mode and 24h mode. So I try to create a new public var and the return value method like this



public class AlarmSettings extends Activity {

public static boolean is24h=false;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm_settings);
CheckBox cb24h;
cb24h = (CheckBox) findViewById(R.id.checkbox_24h);
cb24h.setChecked(true);
}

public boolean getState24()
{
return true;
}}


And when I call it in the another class:



if (id == -1) {
alarmDetails = new AlarmModel();
} else {
alarmDetails = dbHelper.getAlarm(id);
AlarmSettings as = null;
boolean is24h = as.getState24();
if(is24h==true)
timePicker.setIs24HourView(true);
else
timePicker.setIs24HourView(false);

timePicker.setCurrentMinute(alarmDetails.timeMinute);
timePicker.setCurrentHour(alarmDetails.timeHour);


But, it changes nothing! Can you guys show me what's wrong here?


0 comments:

Post a Comment