Displaying lots of text

Hi,

just wodering how other people displaying 'large' amounts of text on the screen. Imagine a string of data that comes back from a JSON request, that might be between 20 and 50 characters long for example. Is there a recommended way to split and display this ?

Just musing.

Thanks for your suggestions ;-)
  • Hi,

    just wodering how other people displaying 'large' amounts of text on the screen. Imagine a string of data that comes back from a JSON request, that might be between 20 and 50 characters long for example. Is there a recommended way to split and display this ?

    Just musing.

    Thanks for your suggestions ;-)


    I wrote a function that's passed the string as well as the font that will be used to display it, and the distance from the top of the screen to start displaying. In the function using a short string of assorted characters, I use "getTextWidthInPixels()" and figure out approximately how many characters will fit within the width of the screen. Using that as a starting point, I take the first chunk of the string, and scan starting at the end of it for a space (so the text breaks on a space). Output in, then grab another chunk that includes the leftover from the first chunk. Then I do the same for how ever many many "chunks" are needed. I've used this with a sting that results in filling up to 5 lines on the screen.

    Once you know how many chars will fit using getTextWidthInPixels() - you could just cut up the originals sting to what will fit, if you don't care about breaking on spaces.

    Here's how it looks in the simulator: