如何增加列表字段所选项目的行高

发布于 2024-12-01 01:47:22 字数 207 浏览 1 评论 0原文

我正在为我的应用程序使用 ListField 来显示列表中的数据。现在我的要求是我想增加列表中所选项目的行高。

为此,我创建了一个 GridFieldManager 并使用此管理器填充我的列表。然后我重写该管理器的 onFocus() 方法。但是,这个方法永远不会被调用。因此,我无法增加所选行项目的高度。

请帮忙。

I am using a ListField for my app to show the data in a list. Now my requirement is that i want to increase the row height of the selected item of the list.

For this, i created a GridFieldManager and populated my list using this manager. I then override the onFocus() method of this manager. But, this method is never invoked. As a result i am unable to increase the height of the selected row item.

Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

左岸枫 2024-12-08 01:47:22

ListField 行均设计为统一大小,因此遗憾的是您无法直接更改一行的大小。您可以通过设置来模拟它,以便上方和下方的行分别在底部和顶部绘制一点焦点颜色。或者,您可以有一个字段仅位于焦点所在行上方的中心。然后使用所选行中的信息重新绘制此“浮动字段”。

ListField rows are all designed to be uniformly sized, so unfortunately you won't be able to directly change the size of one row. It's possible you can emulate it by setting it so that the row above and below draw a little bit of the focus color at the bottom and top respectively. Alternatively, you could have one field that just stays centered above whatever row is focused. Then redraw this "floating Field" with the information from the selected row.

能否归途做我良人 2024-12-08 01:47:22

我成功了。我伪造了 ListField 实现。我删除了 ListField 并将其替换为 VerticalFieldManager。我在 onfocus()onUnfocus() 期间调整了其大小,并使用 sublayout() 更改了该管理器的高度。它的工作方式正是我想要的。

I got it working. I faked the ListField implementation. I removed ListField and replaced it with VerticalFieldManager. I adjusted its size during onfocus() and onUnfocus() and used sublayout() to change the height of this manager. Its working exactly the way i want.

桃扇骨 2024-12-08 01:47:22
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;
}
            }
}
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;
}
            }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文