如何知道黑莓editfield的行号

发布于 2024-10-05 06:57:07 字数 175 浏览 0 评论 0原文

我想知道 EditField

I would like to know the line number in EditField while I am typing some text in this component.

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

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

发布评论

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

评论(1

动听の歌 2024-10-12 06:57:07
  1. 获取编辑字段的宽度。 (int returned) (eg 320 px)

  2. 获取当前文本的字体宽度。 Font 类具有接受字符串参数的 getAdvance() 方法(返回 int)(例如 650 px)

  3. 如果字符串宽度 >编辑字段宽度 您可以将字符串宽度和编辑宽度相除,然后在另一步骤中获取它的模数。 (这里你将得到 2 作为除法,10 将是 yr 模。这意味着你已经填充了两行+在第三行中你有可以适合 10 px 的字符。

我希望它能解决你的问题,但如果你使用任何长单词,请小心,该模块从未使用长单词进行过测试,但我担心长单词结果的准确性。 。

  1. Get the width of the edit field. (int returned) (e.g. 320 px)

  2. Get the font width of your current text. Font class have getAdvance() method that accepts the string parameter (int returned) (e.g. 650 px)

  3. if string width > edit field width you can divide string width and edit width and on the other step get the modulo of it. (here you will get 2 as division and 10 will be yr modulo. That means you have filled two lines + in third line you are having characters that can be fit into 10 px.

I hope it will solve your problem, but be careful if you use any long words, the module had never been tested with long words but I fear about result's accuracy with long words.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文