Disable TextField in J2ME

[亡魂溺海] 提交于 2019-12-08 04:26:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!