java android - how to set html from resources to TextView?

android, html, java, textview

Solution

myTextView.setText(Html.fromHtml(readTxt()));     

//This function will return string which you can set in your textview. And that String have html codes so use Html.fromHtml

 private String readTxt() {
    InputStream inputStream = getResources().openRawResource(R.raw.My_html_file);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    int i;
    try {
        i = inputStream.read();
        while (i != -1) {
            byteArrayOutputStream.write(i);
            i = inputStream.read();
        }
        inputStream.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return byteArrayOutputStream.toString();
  }

Problem

Is there any possibility to load html from res/raw into the TextView? I know I can use WebView, but damn transparency is not always working (not on every device)

Original source

Related problems