有人知道如何使CellList水平定向吗?如果可能,请与UiBinder一起使用,但这不是必需的。

最佳答案

按照Thomas Broyer的建议on the google-web-toolkit groupHow to style GWT CellList?,我们可以向CellList构造函数中注入(inject)新的CSS资源。

用于获取水平格式MyCellList.css的CSS:

/* This file is based on the CSS for a GWT CellList:
 * https://gwt.googlesource.com/gwt/+/master/./user/src/com/google/gwt/user/cellview/client/CellList.css
 * The primary purpose is to arrange for the <div> elements that contain each cell to be laid out inline (horizontally).
 */

/* Using inline-block, following Thomas Broyer's recommendations (with link to justification) here:
 * https://groups.google.com/forum/#!topic/google-web-toolkit/rPfCO5H91Rk
 */
.cellListEvenItem {
    display: inline-block;
    padding: 5px;
}

.cellListOddItem {
    display: inline-block;
    padding: 5px;
}

定义一个这样的新资源:
public interface MyCellListResource extends CellList.Resources {
  public static MyCellListResource INSTANCE = GWT.create(MyCellListResource.class);
  interface MyCellListStyle extends CellList.Style {}

  @Override
  @Source({CellList.Style.DEFAULT_CSS, "MyCellList.css"})
  MyCellListStyle cellListStyle();
}

注入(inject)新样式,并将其传递给CellList的构造函数:
    MyCellListResource.INSTANCE.cellListStyle().ensureInjected();

    CellList<Fare> cellList = new CellList<Fare>(cell, MyCellListResource.INSTANCE);

请注意,新样式将在CellList的DEFAULT样式之后出现在级联中,因此您只需要将所需的修改放入MyCellList.css中。

关于GWT CellList水平,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4374863/

10-10 16:55