Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android webview loading HTML from strings.xml

So i have this in Strings.xml:

<string name="sixpackInfo">
        <html><body><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. </p>

<p><b>Sed dignissim lacinia nunc. Curabitur tortor.</b> Pellentesque nibh. Aenean quam. In sce
</body></html>

    </string>

I try to load and parse this string into a webview.

like so:

wvInformation = (WebView) findViewById(R.id.wvInformation);
        String text = getResources().getString(R.string.sixpackInfo);
        System.out.println(text);
        wvInformation.loadData(text, "text/html", null);

i am getting the lorem ipsum text into the webview but the p tags and b tags arent taken care of. the text just appear as plain text with the markup.

like image 789
sn0ep Avatar asked Oct 08 '22 16:10

sn0ep


1 Answers

<string name="sixpackInfo">
    <![CDATA[<html><body><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. </p>

<p><b>Sed dignissim lacinia nunc. Curabitur tortor.</b> Pellentesque nibh. Aenean quam. In sce
</body></html>
]]>
</string>
like image 74
CooL i3oY Avatar answered Oct 12 '22 10:10

CooL i3oY