• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Displaying large amounts of text.

kihon

Lurker
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?
 
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
 
Back
Top Bottom