How can I count the number of lines in an EditText? Basically in my app I have line numbers and I wanted to make them update on textchange (I already have the textchangelistener set up). Is this possible? :(
Thanks, Alex!
How can I count the number of lines in an EditText? Basically in my app I have line numbers and I wanted to make them update on textchange (I already have the textchangelistener set up). Is this possible? :(
Thanks, Alex!
Lines can be differents:
First case (the easiest):
Second case:
Depends on what you define as "line number". A line in your edittext in "GUI way", which includes the linebreaks your editview does? Or a line in a "coding way" of describing it (having \n at the end)? First one will be quite hard to get, if even impossible. Second one: just count the numbers of \n in the text, plus add another 1 if there is something after the last \n.