i want to split one large string into two part, and their size is not fixed. i开发者_如何学C generate textview at runtime so size is different all the time, so i want to count howmany characters is placed inside this textview. so i format the textview correctly. please help me thanx in advance
I think what you're asking for is the number of characters that would 'fit' in a TextView without clipping or the need for scrolling. All you'd have to do is determine the TextView width and height, and compute the number of characters that would fit.
In pseudo-code:
Width = TextView Width in px
Height = TextView Height in px
row = col = count = 0
while row < Height
col = 0
while col < Width
col = col + (Size of one character in px)
count = count + 1
row = row + (Size of one character in px)
count gives the number of characters that can be displayed in the TextView at a time.
...
TextView tv;
tv.getText().length();
?
No, really - what are you asking? That gives you the length of the text, then you just use that variable to split things up?
精彩评论