How do I add items to GWT ListBox in Uibinder .ui.xml template ?

前端 未结 3 1035
北恋
北恋 2020-12-28 17:55

How to add the listbox items using UiBinder?

3条回答
  •  醉酒成梦
    2020-12-28 17:59

    GWT ValueListbox otherwise know as a ComboBox or Dropdown component. Another example that also demonstrates populating the list.

    UiBinder...

     
    

    Editor...

    @UiField(provided = true)
    ValueListBox subCategory = new ValueListBox(
      new Renderer() {
    
        @Override
        public String render(String object) {
          String s = "Cats";
          if (object != null) {
            s = object.toString();
          }
          return s;
        }
    
        @Override
        public void render(String object, Appendable appendable)
            throws IOException {
          render(object);
        }
    
    });
    

    Constructor...

    List values = new ArrayList();
    values.add("Animal Shelters and Rescues");
    values.add("Birds");
    values.add("Cats");
    values.add("Dogs");
    values.add("Other Pets");
    values.add("Rabbits");
    subCategory.setAcceptableValues(values);
    

提交回复
热议问题