如何自定义ObjectListField?
是否可以按照以下设计自定义Objectfieldlist?
----------------------------
ROW#1 ROW NAME
row details
---------------------------
ROW#2 ROW NAME
row details
---------------------------
ROW#3 ROW NAME
row details
---------------------------
行名称的字体将大于行详细信息
基本上我需要在 ObjectListField 的行中包含 2 个文本行。**或任何其他方法或建议,因为我可能是错的,**请指导我它的紧急情况,并且是黑莓的一些新内容发展。
Is it possible to customize Objectfieldlist according to following design?
----------------------------
ROW#1 ROW NAME
row details
---------------------------
ROW#2 ROW NAME
row details
---------------------------
ROW#3 ROW NAME
row details
---------------------------
Row Name will be in bigger font than row details
Basically I need 2 text rows in a Row of ObjectListField.**OR any other method or suggestion as I might be wrong,**pls guide me its urgent and am some what new to Blackberry Development.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ObjectListField
并不是真正执行此操作的正确方法 - 它实际上被设计为ListField
的快速版本,适合您只需要简单的字符串列表的情况。您应该扩展
ListField
本身,并提供您自己的ListFieldCallback
实现,以根据您的数据模型呈现列表。使用ListField.setCallback
设置回调。ListFieldCallback.drawListRow
为您提供一个Graphics
上下文,因此您可以绘制任何您想要的内容,包括多行文本。另请确保在列表字段上调用 ListField.setRowHeight
以使行足够高以容纳 2 行文本(默认高度是字体高度,因此您只能容纳 1 行文本) )。示例代码类似于(这并不完整,如果没有其他代码就无法编译):
ObjectListField
isn't really the right way to do this - it's really designed as a quick version ofListField
for those times when you just need a simple list of strings.You should extend
ListField
itself, and provide your own implementation ofListFieldCallback
that renders your list based on your data model. UseListField.setCallback
to set your callback.ListFieldCallback.drawListRow
gives you aGraphics
context, so you can draw whatever you want, including multiple lines of text. Also make sure to callListField.setRowHeight
on your listfield to make the rows high enough for 2 lines of text (the default height is the font height, so you'd only have room for 1 line of text).Sample code is something like (this is not complete and will not compile without some other code):