0

I am using below lines of code to show html pages on my application but my app is too slow when scrolling. Can I use another method to show the text? Can it be by html page or another method? or use listview to show my text? or is it necessary to create layout for every text page?

Thanks.

ck.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            webView.getSettings().setJavaScriptEnabled(true);
            webView.loadUrl("file:///android_asset/ck.html");
            ((Button)findViewById(R.id.cb)).setVisibility(View.GONE);((Button)findViewById(R.id.geri)).setVisibility(View.VISIBLE); ((Button)findViewById(R.id.db)).setVisibility(View.GONE); ((Button)findViewById(R.id.bb)).setVisibility(View.GONE); ((Button)findViewById(R.id.ck)).setVisibility(View.GONE);
        }
    });
    cb.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
Shree
  • 354
  • 2
  • 21
e.zver
  • 31
  • 5
  • this will help you [How to display HTML in TextView?](https://stackoverflow.com/questions/2116162/how-to-display-html-in-textview) – Learning Always Dec 25 '17 at 11:46
  • You are using a webview, ofcourse it will be slower. You can display your texts as hardcoded Strings in your String.xml file and set them to your TextView's in your layout. – Ege Kuzubasioglu Dec 25 '17 at 11:46

2 Answers2

0

You Can Use This Library :-

https://github.com/PrivacyApps/html-textview

HtmlTextView is an extended TextView component for Android, which can load HTML and converts it into Spannable for displaying it. It is a replacement for usage of the WebView component, which behaves strange on some Android versions, flickers while loading, etc.

Saurav Prakash
  • 588
  • 1
  • 5
  • 26
-1

My issue solved using below code you can try this one:

// get our html content
   String htmlAsString = getString(R.string.html);
   Spanned htmlAsSpanned = Html.fromHtml(htmlAsString); // used by TextView

// set the html content on the TextView
   TextView textView = (TextView) findViewById(R.id.textView);
   textView.setText(htmlAsSpanned);

<resources>
<string name="html">
    <![CDATA[
    <h1>Main Title</h1>
    <h2>A sub-title</h2>
    <p>This is some html. Look, here\'s an <u>underline</u>.</p>
    <p>Look, this is <em>emphasized.</em> And here\'s some <b>bold</b>.</p>
    <p>This is a UL list:
    <ul>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    </ul>
    <p>This is an OL list:
    <ol>
    <li>One</li>
    <li>Two</li>
    <li>Three</li>
    </ol>

</string>
 </resources>

Hope this will help you if not than inform me

Mahesh Vayak
  • 1,056
  • 12
  • 25