Blackberry - Disable Save option in BasicEditField?

房东的猫 提交于 2019-12-30 10:13:49

问题


I am using a basiceditfield to take input from the user to do some simple string search. But if i type a few letters and wish to go back without continuing the search, it automatically asks me whether to save the contents of the field. I don want this to happen. Can i in any way disable the "Changes made!-save-discard-cancel" option in basiceditfield(or any editfield for that matter)????please help!!!


回答1:


Try adding this to your MainScreen class:

protected boolean onSavePrompt() {
        return true;
    }



回答2:


Another way would be to override the dirty state logic on your Screen class like this:

public boolean isDirty() { return false; }

Of course you can also just override that same method on a subclass of your Field, and that too should probably work. (assuming you still want to do dirty-state-tracking of other fields on the screen.)




回答3:


modify onClose method of Screen

 public boolean onClose() {
   this.close();
   return true;
}


来源:https://stackoverflow.com/questions/2461403/blackberry-disable-save-option-in-basiceditfield

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