开发者

Android multi-line textview - character count of a particular line?

开发者 https://www.devze.com 2023-03-21 09:33 出处:网络
I\'m trying to get the character count of a particular line of a multi-line textview.Based on other posts, I\'ve gotten the Layout of the textview in question.I see several methods that pass in an (in

I'm trying to get the character count of a particular line of a multi-line textview. Based on other posts, I've gotten the Layout of the textview in question. I see several methods that pass in an (int line), but none that return a character count o开发者_高级运维f a particular line? Am I just missing it? Any help would be appreciated.


This will split the text in the textview by lines.

String text;
String[] lines = text.split("\\r?\\n");
int characterCount = lines[0].length();


if your just trying to get the count of a string, have you tried String.length(myString) to return a count of how many characters are in the string?

0

精彩评论

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