I have a multiline edit text in which the number of lines can grow up to any number.
Does android provide any functionality to get content of any particular line?
Suppose total number of lines are three and i want to read only second line.
A EditView in Android does wrap its text so it fits in the view. That means that you have to determine a lines start and end position to read it and then you can extract it from the full contentstring. This post already explained this issue.
So your code would be:
// change to your needs
int linenumber = 1;
int startPos = myTextView.getLayout().getLineStart(linenumber);
int endPos = myTextView.getLayout().getLineEnd(linenumber);
String theLine = myTextView.getText().toString().substring(startPos, endPos);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With