在列表框GWT中修剪的单词之间的空格



我在GWT项目中使用ListBox。ListBox填充多个记录,每个记录都有多个单词。记录之一可能在单词之间具有多个空间。有没有办法保存这些空间。我尝试使用{white空加空间:pre;}提供CSS到ListBox,但它不起作用。

您必须通过非破坏空间替换每个空间字符: 。不幸的是,ListBox.addItem(String)会忽略那些 's。

这是使用GWT Element API的解决方法:

    Element listElement = theListBox.getElement();
    OptionElement optionElement = Document.get().createOptionElement();
    optionElement.setInnerSafeHtml(SafeHtmlUtils.fromTrustedString("   you should see 3 spaces before this"));
    listElement.appendChild(optionElement);

最新更新