I would like to know the line number in EditField while I am typing some text in this component.
Asked
Active
Viewed 395 times
1 Answers
1
Get the width of the edit field. (int returned) (e.g. 320 px)
Get the font width of your current text.
Font class have getAdvance() method that accepts the string parameter
(int returned) (e.g. 650 px)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.

Prasham
- 6,646
- 8
- 38
- 55
-
P.S. I would like to have a feedback on this. – Prasham Nov 30 '10 at 06:08
-
Thanks in advance. But the EditField will set some word to new line, so the current line has more space. This problem can not solve by your solution. Do you have other solution? – Mojiiz Nov 30 '10 at 07:48
-
I have mentioned about it, if there are some large words at the end of the line like `abbreviated` the edit field itself puts this into a new line and we face an error `(Not proper length)`, i have used this module but we never allowed user to enter a word more than 5 chars. So there was no scope of encountering this error. But you can implement it and find a workaround... Best of luck.. and sorry for long comment – Prasham Nov 30 '10 at 08:53
-
Could you give me some suggestion about how can I create my EditField like BB messenger which support both of text and emoticon image. – Mojiiz Nov 30 '10 at 09:05
-
edit fields can't have images, but if you are comfortable with text smileys it's possible. And you can later show them in a rich text field with relevant images – Prasham Nov 30 '10 at 09:41
-
@Mojiiz: By the way.. are you developing a chat messenger – Prasham Nov 30 '10 at 09:42
-
@MobileDev123 Yes, currently I am developing chat messenger program. I am studying in the last year of Computer Science. I interest to develop application on mobile phone. – Mojiiz Nov 30 '10 at 09:47