1. Check out our companion app, Forums for Android! Download from Google Play

Displaying large amounts of text.

Discussion in 'Application Development' started by kihon, Jun 25, 2010.

  1. kihon

    kihon New Member
    Thread Starter

    Jun 25, 2010
    Hi All, Im writing an app to display a large amount of text via a TextView. (Effectively an EReader app). Currently I decode the book into a single String and set it as the text for the TextView. Is this a bad thing to do - ie having a large string? Would it be better to dynamically extract a few pages at a time? (though this may mean having to do the scrolling code manually). Some background: The ebooks are in ereader/peanut press format. Each book is stored as a single pdb file, which contains multiple blocks of data about 4k each. Each block is normally made up of text compressed using zlib. The easiest method for displaying the text is to loop through each block and inflate the data into a string, and concatenate the strings together. (which could result in a string containing ~2 mb of text). The alternative is to identify approximately which block the view is in, and only inflate the text areas around the current view. What do you guys think?


  2. SWhite

    SWhite Member

    Apr 15, 2010
    Student, Developer
    i would say find out how much text you want to display at a time, then pre-inflate a couple blocks more than that in either direction. Instead of the scroll containers, id make my own buttons whose click events include the inflation of a block in the direction and removing a blocks-worth of text off the other end of the string, and re-setting the text. this should allow for a fairly seamless scrolling as the inflation happens off-screen.

    i hope this makes sense, and i hope it helps

Share This Page