0
In the code snippet below I disable the freight value edition when the freight type is SIF put the code snippet Library.editTexPermission(edtFrete, true);
that should release editText edition does not work in the following situation: Select SIF and then select FOB. Ask how can I release the edition of edtFrete
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) {
}
});
Follow below the code snippet from editTexPermission
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);
}
You can post the code of
editTexPermission
?– Marco Giovanni
Ready Marco, code posted in question
– Benjamim Mendes Junior
I didn’t really understand the context of the situation, but to enable and disable the field you should not use the
editText.setEnabled(true/false)
?– Marco Giovanni
Yeah, as I said this excerpt was not mine, I even thought that the Library was something of Android itself! With simple search on the net found that the
setKeyListener
prevents any kind of action on theEditText
, even selecting and copying your content but it is complicated to make it editable again without having to reload Ragment. I will change the text to what you suggested. Please post as reply so you can positive it.– Benjamim Mendes Junior