开发者

Access text of Multiline TextView in Android

开发者 https://www.devze.com 2023-02-20 19:25 出处:网络
I want to access text of particular line in a multi-line TextVi开发者_Go百科ew. Any suggestions on how I could do this?Fetch the Layout (android.text.Layout) of the TextView by calling mTextView.getLa

I want to access text of particular line in a multi-line TextVi开发者_Go百科ew. Any suggestions on how I could do this?


Fetch the Layout (android.text.Layout) of the TextView by calling mTextView.getLayout(); There you can for instance use the getLineStart or getLineEnd methods to get the offset of the text. That combined with getText and used using normal String operations should probably be enough for u!


By default, text view is multi line. Set the text with new line characters for ex. "First line \nSecond line".

Another option is listed here : https://stackoverflow.com/questions/2610280/how-to-get-multi-line-text-on-a-button-in-android

0

精彩评论

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