In the code snippet below I disable the freight value edition when the freight type is SIF, but the% code_code that should release the editText edition does not work in the following situation: Select SIF and then select FOB. Question How can I release the edition of Library.editTexPermission(edtFrete, true);
after blocking it?
spFrete.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
switch (spFrete.getSelectedItemPosition()) {
case 0: { //FOB
Library.editTexPermission(edtFrete, true);
break;
}
case 1: { //SIF
Library.editTexPermission(edtFrete, false);
edtFrete.setText("0.0");
break;
}
}
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
The code snippet of edtFrete
with it becomes evident how the edit is blocked now the question is: how to set the KeyListener again?
public static void editTexPermission(EditText editText, Boolean enabled) {
editText.setFocusable(enabled);
if (!enabled)
editText.setKeyListener(null);
}