Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to page a long text?
    primarykey
    data
    text
    <p>I have a long text and fixed size textView. How can show the text page by page? Users will interactive with the program in this way: He swipe left or right to turn to next or previous page.</p> <p>Currently, I create a PageManager to do this job. But it's very limited. The core code to process the text is:</p> <pre><code>while (true) { newLineIndex = TextUtils.indexOf(content, '\n', processIndex); if (newLineIndex == -1) {// till the end of content charCount = paint.breakText(content, processIndex, content.length(), false, leftLines * lineWidth, width); } else { charCount = paint.breakText(content, processIndex, ++newLineIndex, false, leftLines * lineWidth, width); } leftLines = (int) ((leftLines * lineWidth - width[0]) / lineWidth); processIndex += charCount; if (leftLines &lt; 1 || processIndex &gt;= content.length()) { page = new Page(); page.endIndex = processIndex; page.startIndex = pageBaseLine; page.content = content.subSequence(page.startIndex, page.endIndex); result.add(page); pageBaseLine = processIndex; leftLines = lineNumber; } if (processIndex &gt;= content.length()) { break; } } </code></pre> <p>The limitation is the page may truncate the text like </p> <pre><code>|A lon| |g wor| |d man| </code></pre> <p>// a long word man</p> <p>or incorrec lines due to word wrapping:</p> <p>//Page Manager calculates this(2 lines):</p> <pre><code>|a sentence with loooooooo| |ooong word abcdefghijklmn| </code></pre> <p>//But actually in text view(3 lines):</p> <pre><code>|a sentence with | |looooooooooong word | |abcdefghijklmn | </code></pre> <p>So the final line count is more than calculation. So my page manager is stupid. Would any one help me? thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload