我正在使用 SuggestBox 让用户选择值。 但是,当列表中只有一个值时,我会在 SuggestBox 中设置该值,并且我希望该字段不可编辑。
我正在尝试以下操作,但现在该组件在 UI 上不可见。
sgstBox.getTextBox().setEnabled(false);
这也不起作用
sgstBox.getTextBox().setReadOnly(true);
最佳答案
两个未经测试的解决方案 found on Google groups :
public static void setEnabled(SuggestBox sb,boolean enabled) {
DOM.setElementPropertyBoolean(sb.getElement(), "disabled", !enabled);
}
和
//pass in your own TextBox when you construct the SB:
TextBox tb = new TextBox();
SuggestBox sb = new SuggestBox(oracle, tb);
//...and later disable the TextBox:
tb.setEnabled(false);
关于java - 如何在 GWT 中禁用 SuggestBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3108152/