本文介绍了获取列表项的行包,而不是显示省略号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用code下面让产生格式图像,标题和列表项文本区域的布局。结果
我想获得它看起来像Twitter的应用程序布局 - 在它是如何得到鸣叫包,什么条件我缺少
平台详细信息:
BB OS 5.0 +
code:
保护无效sublayout(INT宽度,高度INT){
尝试{
删除所有();
}赶上(例外前){ } MyTitleField lblTitle =新MyTitleField(info.title); //扩展的LabelField
lblDesc的LabelField =新的LabelField(info.description,LabelField.ELLIPSIS)
{
保护无效布局(INT宽度,高度INT){
// TODO自动生成方法存根
super.layout(宽度,高度);
}
}; BitmapField bmfIcon =新BitmapField(info.icon);
加(lblTitle);
加(lblDesc);
加(bmfIcon); INT iconHeight = bmfIcon.getBitmapHeight();
INT fontHeight = Font.getDefault()的getHeight()。
INT preferredWidth =宽度; //获取preferredWidth(); 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,GET preferredHeight());
}
解决方案
- 首先,你需要为icchanobot建议摆脱省略号风格。
- 然后你需要添加在
VerticalFieldManager
(HorizontalFieldManager
将工作太)在建议这个答案。
以下code段
字符串longString =这是一个VerticalFieldManager内的LabelField。这是你的问题http://stackoverflow.com/questions/7641753/get-list-item-row链接-to-总结INSTEAD-OF-秀-省略号VerticalFieldManager VFM =新VerticalFieldManager(Manager.USE_ALL_WIDTH | Manager.NO_HORIZONTAL_SCROLL);
vfm.add(新的LabelField(longString));
加(VFM);
结果
产生
I used the code below to get produce a layout that formats an image, a title and a text region in a list item.
I would like to get it to look like the Twitter apps layout - in terms of how it gets the tweet to wrap, what am I missing?
Platform details:BB OS 5.0+
Code:
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());
}
解决方案
- First, you need to get rid of ELLIPSIS style as icchanobot suggested.
- Then you need to add your label field inside a
VerticalFieldManager
(HorizontalFieldManager
will work too) as suggested in this answer.
The following code snippet
String longString = "This is a LabelField inside a VerticalFieldManager. Here is a link to your question http://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);
produces
这篇关于获取列表项的行包,而不是显示省略号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!