问题
Is it possible to dynamically make TextField
element disabled and enabled during the run time in Java ME?
回答1:
according to API documentation, setConstraints(TextField.UNEDITABLE) could do something like that:
Sets the input constraints of the TextField...
Note if you need to preserve contents and modifier flags, parameter passed to above method might require some tweaking, like
setConstraints((getConstraints() & TextField.CONSTRAINT_MASK)
| TextField.UNEDITABLE) // "disable" - set UNEDITABLE
above to disable, and to enable back, something like:
setConstraints((getConstraints() & TextField.CONSTRAINT_MASK))
// "enable" - cleans up TextField.UNEDITABLE
来源:https://stackoverflow.com/questions/7842127/disable-textfield-in-j2me