jeudi 26 novembre 2015

Codename One - updating Enable state of Spinner

Problem

I have 1 CheckBox and 2 Spinners (Date and Time) in the same container. I initially set both Spinners "not Enabled". Then, when the user taps on the checkbox, both spinners should be set to "Enable" and when user taps again, they should go back to "not Enabled"

Question

When I run my simulator I tap on the CB and both spinners are set to "Enable" just fine, but when I tap again, nothing happens. Can you help me?

Code

Override 
protected void onNuevo_CheckBoxAction(Component c, ActionEvent event) {

    com.codename1.ui.CheckBox cbx = (com.codename1.ui.CheckBox)findByName("CheckBox",c);
    boolean estado = cbx.isEnabled();

    Picker pHora = (com.codename1.ui.spinner.Picker)findByName("PickerHora",c);
    Picker pFecha = (com.codename1.ui.spinner.Picker)findByName("PickerFecha",c);
    pHora.setEnabled(estado);
    pFecha.setEnabled(estado);
}




Aucun commentaire:

Enregistrer un commentaire