Roger Roger - 10 months ago 83
Android Question

EditText.setFocusable(false); can't be set to true. :/

A very strange situation, I've got this code that is supposed to make an EditText filed uneditable if SpnSelected.equals("Service") and editable again, if its something else.

final EditText etAdd = (EditText)dialogAddTextView.findViewById(R.id.etSymb);

if ( SpnSelected.equals("Service") )
{
etAdd.setFocusable(false);
TextView tvInfo = (TextView)dialogAddTextView.findViewById(R.id.tvAddTextInfo);
}
else
{
etAdd.setFocusable(true);
TextView tvInfo = (TextView)dialogAddTextView.findViewById(R.id.tvAddTextInfo);
}


It does make it uneditable ok, but it doesn't bring the ability to edit back with etAdd.setFocusable(true);

Any ideas what to do about it? Thanks! :)

Answer Source

Try

etAdd.setFocusableInTouchMode(true);
etAdd.setFocusable(true);

instead of just

etAdd.setFocusable(true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download