Author: a drop of blue
/*** Split a long string into a String Array Based on the specified width and font ** @ Param longstring * used to split a long string * @ Param font * used to measure the font of the string width * @ Param width * display the width of a single line string on the device * @ return split into a string array */private string [] splitlongstring1_stringarray (string longstring, font font, int width) {If (font. stringwidth (longstring) <= width) {return New String [] {longstring};} else {int stringlength = longstring. length (); char [] chars = longstring. tochararray (); vector v = new vector (); int offset = 0, length = 1; while (Offset + Length <stringlength) {If (font. charswidth (chars, offset, length) <width) {length ++;} else {v. addelement (longstring. substring (offset, offset + length); offset = offset + length; length = 1 ;}} if (offset <stringlength) {v. addelement (longstring. substring (offset);} string [] strings = new string [v. size ()]; V. copyinto (strings); Return strings ;}}