【问题标题】:Get list item row to wrap instead of show ellipsis获取要换行的列表项行而不是显示省略号
【发布时间】:2013-11-14 02:27:20
【问题描述】:

我使用下面的代码生成了一个布局,用于格式化列表项中的图像、标题和文本区域。
我想让它看起来像 Twitter 应用程序布局 - 就它如何包装推文而言,我错过了什么?

平台详情: BB OS 5.0+

代码:

protected void sublayout(int width, int height) {
    try {
        deleteAll();
    } catch (Exception ex) {

    }

    MyTitleField lblTitle = new MyTitleField(info.title);//extends LabelField
    LabelField lblDesc = new LabelField(info.description , LabelField.ELLIPSIS)
    {
        protected void layout(int width, int height) {
            // TODO Auto-generated method stub
            super.layout(width, height);
        }
    };

    BitmapField bmfIcon = new BitmapField(info.icon);
    add(lblTitle);
    add(lblDesc);
    add(bmfIcon);

    int iconHeight = bmfIcon.getBitmapHeight();
    int fontHeight = Font.getDefault().getHeight();
    int preferredWidth = width;//getPreferredWidth();

    int startY = (rowHeight - iconHeight)/2;
    layoutChild(bmfIcon, bmfIcon.getBitmapWidth(), bmfIcon.getBitmapHeight());
    setPositionChild(bmfIcon, 5, startY);

    int textWidth  = preferredWidth - (bmfIcon.getBitmapWidth() +10 );
    int textStartX = bmfIcon.getBitmapWidth() + 10;
    layoutChild(lblTitle, textWidth  ,
            fontHeight + 1);
    setPositionChild(lblTitle, textStartX, startY);

    int descHeight = rowHeight - (startY+fontHeight+2);
    layoutChild(lblDesc, textWidth  , descHeight);

    setPositionChild(lblDesc, textStartX, (startY+fontHeight+2));

    setExtent(preferredWidth, getPreferredHeight());
}

【问题讨论】:

  • 你不能在这里摆脱 ELLIPSIS 风格吗:LabelField lblDesc = new LabelField(info.description)
  • 是的,我可以,但它只是一直跑到一边,没有包裹起来。
  • 你能告诉我我必须下载哪个版本的 JDE 来进行 bakberry-os5 开发吗?我用谷歌搜索找不到它

标签: java blackberry listitem blackberry-os5


【解决方案1】:
  1. 首先,您需要摆脱 icchanobot 建议的 ELLIPSIS 样式。
  2. 然后您需要按照this 答案中的建议在VerticalFieldManager 中添加标签字段(HorizontalFieldManager 也可以使用)。

以下代码sn-p

String longString = "This is a LabelField inside a VerticalFieldManager. Here is a link to your question https://stackoverflow.com/questions/7641753/get-list-item-row-to-wrap-instead-of-show-ellipsis";

VerticalFieldManager vfm = new VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.NO_HORIZONTAL_SCROLL);
vfm.add(new LabelField(longString));
add(vfm);


产生

【讨论】:

    猜你喜欢
    • 2012-03-29
    • 2019-10-23
    • 2019-02-13
    • 2011-11-23
    • 2020-01-29
    • 2015-11-21
    • 1970-01-01
    • 2012-03-20
    • 1970-01-01
    相关资源
    最近更新 更多