Blackberry ListField Text Wrapping - only two lines -


Within my listfind, I want to be able to pick any long string, and just wrap the first line within the screen Take the width, and just take the remaining string and display it below and the rest of the pillar. Right now, this is what I'm detecting in my Draw Paint Call:

int totalWidth = 0; Int charWidth = 0; Int lastIndex = 0; Int spaceIndex = 0; Intlineindex = 0; String first LAN = ""; String second = ""; Boolean isSecondLine = false; For (int i = 0; i & lt; long string.length (); i ++) {charWidth = font.get default (). GetAdvance (string.valuef (long string. Chartart (I))); // system.out.printlean (inch width: "+ charwood); if (long string.chart (i) == '') spaceIndex = i; if ((fourvuth + total width)> (this.getWidth ( ) - 32)) {//g.drawText(longString.substring(lastIndex, spaceIndex), Exposure, Y + _padding, DryStyle, LEFT, W- Exposes; lineIndex ++; System.out.println ("Attract to Current line for "+ line index"); / * if (lineindex = 2) {int idx = i; System.out.println ("first line" + long string. Substring (final index, space indicator); System Out.println ("Second Pt "Long string". Substring (space indicator + 1, long string. (Langhe ());} * / / // first line = long string. Substring (last index, space index); firstLine = long string. Substring ( 0, space index); //System.out.println (free new line: "+ first line); // isSecondLine = true; // xpos = 0; // y + = font.get default (). GetHeight (); I = Space Index + 1; Last Index = I System.out.println ("The rest of the string:" + long string of busting (last index, long string.) (Langhe ()); CharWidth = 0; Total with = 0; } Total with + = fourths; System.out.println ("Total Width:" + total width); //g.drawText(longString.substring (lastIndex, i + 1), Expo, Y + (_padding * 3) +4, Draw Style .ELLIPSIS, w - xpos); // seconds = long string. Substring (final index, i + 1); SecondLine = long string. Substring (last index, long string. Lamp ()); // isSecondLine = true; }

Now it actually does a great job of wrapping any string (assuming the value of the Y value was properly offset and after the string width is greater than the screen width , The remaining string later), however, every time I try to get the first two rows, it always returns to the last two rows of the string, if it goes beyond two rows, do such things Is a better way, because I'm fresh out of ideas?

I'm not completely sure that I think you have any questions but I think Like if you want to wrap a word and give algorithms after two rows, if that is the case then you hope that you will be pointed in the right direction. string line 2; If (font.getAdvance (inputString) & lt; = width) {line1 = inputString; Line 2 = ""; } And {int charsInLine1 = countCharsInLine (inputstring, 0, inputstring.lamp () - 1, width, font); Intlinebrake = inputstring.list indexoff ('', chars inline 1); If (drawings == -1) linebreak = color line 1; Line 1 = inputstrings. Substring (0, lineback); Line 2 = inputstrings. Substring (linereak + 1, inputstring.line ()); If (font.getAdvance (line2) & gt; width) {int charsInLine2 = countCharsInLine (line2, 0, inputstring.length () - 1, width - font.getAdvance ("..."), font); Line2 = line2.substring (0, charactersineline 2) + "..."; }} System.out.println ("line1:" + line1); System.out.println ("line2:" + line2); } Int countCharsInLine (string str, int min, int max, int width, font font) {If (min> min = max) return max; Int estimate = minimum + (max - min) / 2; Int advance = font.getAdvance (str, 0, estimate); If (advance & lt; width) return calculation statement line (str, estimate + 1, maximum, width, font); And if (advance> width) return countwarnenline (str, min, estimate -1, width, font); And guess; }


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -