开发者

How can I know the line number of editfield of blackberry

开发者 https://www.devze.com 2023-01-27 14:39 出处:网络
I would like to know the开发者_高级运维 line number in EditField while I am typing some text in this component.

I would like to know the开发者_高级运维 line number in EditField while I am typing some text in this component.


  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消