【发布时间】:2011-08-24 11:33:15
【问题描述】:
我正在为我的应用程序使用ListField 以在列表中显示数据。现在我的要求是我想增加列表中所选项目的行高。
为此,我创建了一个GridFieldManager 并使用此管理器填充了我的列表。然后我覆盖了这个经理的onFocus() 方法。但是,永远不会调用此方法。因此,我无法增加所选行项的高度。
请帮忙。
【问题讨论】:
标签: blackberry listfield
我正在为我的应用程序使用ListField 以在列表中显示数据。现在我的要求是我想增加列表中所选项目的行高。
为此,我创建了一个GridFieldManager 并使用此管理器填充了我的列表。然后我覆盖了这个经理的onFocus() 方法。但是,永远不会调用此方法。因此,我无法增加所选行项的高度。
请帮忙。
【问题讨论】:
标签: blackberry listfield
ListField 行都被设计成统一大小,所以很遗憾你不能直接改变一行的大小。您可以通过设置来模拟它,以便上方和下方的行分别在底部和顶部绘制一点焦点颜色。或者,您可以让一个字段保持居中于所关注的任何行之上。然后用所选行中的信息重绘这个“浮动字段”。
【讨论】:
ListField 中使用的标签的字体高度。
我让它工作了。我伪造了ListField 实现。我删除了ListField 并将其替换为VerticalFieldManager。我在onfocus() 和onUnfocus() 期间调整了它的大小,并使用sublayout() 来改变这个经理的高度。它的工作方式正是我想要的。
【讨论】:
you can increase the row height/font text/...
as ultimately, all of the api's call canvas's paint methods
how to do:
//try playing with the font_type,font height
Font myFont = Font.getDefault().derive(Font.PLAIN, 14, Ui.UNITS_px);
private class ListCallback implements ListFieldCallback {
public void drawListRow(ListField list, Graphics g, int index, int y, int w) {
g.setFont(myFont);
String text = (String)listElements.elementAt(index);
g.drawText(text, 0, y, 0, w);
//you can increase the height of a particular row in the height parameter.
// if you want it to be specific, put an 'if conditon'
EX: if(index=1)
{
w+=10;
}
}
}
【讨论】: