Loading HTML with CSS string on Android Web View


Hi there!

In this tutorial we are going to load HTML string on an Android Web View.

Let’s start by adding a Web View on your Layout file.

After adding the WebView element on the “.xml” file, the Graphical Layout must be look like the image below.

Next, we go to the activity file or the “.java” class and declare the Web View element inside.

After successfully declaring the Web View to your activity file the next thing to do is to load your HTML structure inside your Web View Layout using this codes below.

Create a String variable and consider your HTML structure as String and replace all ( ” ) with ( ‘ ) to avoid malfunction or use ( \” ) instead.

Now we’re almost done, all we need to do is to call the function() on the onLoad/onCreate of the activity.

This method is effective when making static pages of your Application dealing with texts to improve interface by using CSS.

Download “WebView_simple.rar” WebView_simple.rar – Downloaded 44 times – 1 MB