当前位置: 代码迷 >> BlackBerry >> 黑莓开发时关于布局的一些有关问题。
  详细解决方案

黑莓开发时关于布局的一些有关问题。

热度:5030   发布时间:2013-02-26 00:00:00.0
黑莓开发时关于布局的一些问题。。。。。
如, HorizontalFieldManager 为横排的 VerticalFieldManager 为竖排的,他们怎么设置宽带和高度呢?
  VerticalFieldManager  怎么让里面的Field为两排呢?
------最佳解决方案--------------------------------------------------------
自己重载sublayout
示例: 下面的是将field横向平均排列
protected void sublayout(int maxwidth, int maxheight) {
  final int count = getFieldCount();
  if (count > 0) {
    int x = 0;
    final int widthPerField = maxwidth / count;
    int w = widthPerField;
    for (int i = 0; i < count; i++) {
      Field f = getField(i);
      if (i == count - 1) {
        w = maxwidth - x;
      }
      setPositionChild(f, x, 0);
      layoutChild(f, w, maxheight);
      x += widthPerField;
    }
  }
  setExtent(maxwidth, maxheight);// 设置宽度和高度
}
  相关解决方案