Skip to main content

WebView for a HTML page display in Android app.

This exercise is an enhancement of the previous article –> Sound manipulation using MediaPlayer. Read the previous article first to understand this article better.

This is an exercise to practise using WebView to display a HTML file on your Android app. Found this nice suggestion by Mathias Lin at http://stackoverflow.com/questions/3058164/android-scrolling-an-imageview . The main reason I’m using this is because I need to display image that bigger than the screen. Putting the image in a HTML page, and view the HTML page using this WebView widget will automatically invoke the scrollbars. WebView will act as your HTML page display (using WebKit browser).

image

STEP 1: Prepare the HTML page, and put it in folder assets.

image

STEP 2: To use this Widget, just add WebView widget in the UI (main.xml);

image

STEP 3: In order to make this widget works properly, you must add INTERNET uses-permission in A

image

STEP 4: Define the WebView widget, and load the local HTML file. Use the following codes;

        //define webview
        WebView webview = (WebView)findViewById(R.id.webview);
        webview.setHorizontalScrollBarEnabled(false);
        webview.loadUrl(file:///android_asset/01fatihah.html);

image

The complete project source is as below… Have fun!

Comments

  1. Terbaik bro!..Nice mobile application. Bole di enhance kan lg...Pasni kasi jual lah...hehe

    ReplyDelete
  2. Aku buat 2 version, Melayu aku bagi free, English baru charge 1USD. Boleh dpt kat Android market. Hopefully sempat publish immediate lps raya...

    ReplyDelete
  3. Mender2 camni kalu nak jual boleh, tp kalu nak bagi free lagi baik. Manfaat kat ummah. MO lain nak dpt revenue mungkin boleh dptkan sponsor, eg SalamFone...

    ReplyDelete
  4. OR download from here http://khirulnizam.com/m-mathurat/mfatihah.rar

    ReplyDelete
  5. Hi, Thank. I try this this n its working...
    I have html in which their is embed video in it in local HTML. I want to play video in html in WebView. Tried but no luck. Any guideline. Thanks

    ReplyDelete

Post a Comment

Popular posts from this blog

Several English proverbs and the Malay pair

Or you could download here for the Malay proverbs app – https://play.google.com/store/apps/details?id=net.kerul.peribahasa English proverbs and the Malay pair Corpus Reference: Amir Muslim, 2009. Peribahasa dan ungkapan Inggeris-Melayu. DBP, Kuala Lumpur http://books.google.com.my/books/about/Peribahasa_dan_ungkapan_Inggeris_Melayu.html?id=bgwwQwAACAAJ CTRL+F to search Proverbs in English Definition in English Similar Malay Proverbs Definition in Malay 1 Where there is a country, there are people. A country must have people. Ada air adalah ikan. Ada negeri adalah rakyatnya. 2 Dry bread at home is better than roast meat home's the best hujan emas di negeri orang,hujan batu di negeri sendiri Betapa baik pun tempat orang, baik lagi tempat sendiri. 3 There's no accounting for tastes We can't assume that every people have a same feel Kepala sama hitam hati lain-lain. Dalam kehidupan ini, setiap insan berbeza cara, kesukaan, perangai, tabia...

Simple search – result appears in the same page

This PHP code is a simple search example. It needs the user to enter a name and the PHP script will to the searching by the name provided by the user in the text box. <form name='search' method='get' action=''> Insert the firstname <input type='text' name='txtname'> <input type='submit' value='search name'> </form> <?php //database connect $db=mysqli_connect("localhost","root","","mycompanyhr"); //checking database connection if ($db==false) { echo "Connect failed: ". mysqli_connect_error($db); exit(); } else { echo "Connection successful"; } $n=$_GET['txtname']; $sql="select EMPNO, FIRSTNAME, LASTNAME, WORKDEPT, PHONENO from employee where FIRSTNAME like '%$n%' "; $rs=mysqli_query($db,$sql); if($rs==false){ echo ("Query cannot be executed!<br>"); echo ("SQL Error : ".mysqli_error($db)); } else...

Mobile Apps using HTML interface with jQueryMobile

This is the main tutorial for developing a mobile web app using the HTML  interface with jQueryMobile. The series contains tutorial on how to use HTML and jQueryMobile to construct the app’s interface, PHP+MySQL to run the back-end, AJAX, using phoneGap/Cordova to generate Android APK, and lastly to upload to Google Play Store. These are the link of completed tutorials related to Mobile Web Apps Development Mobile Apps using HTML interface with JQUERYMOBILE (this page) Complete code sample of Mobile Web Apps with FRONT-END and BACK-END Using AJAX to populate data from mobile web interface Generating APK using BUILD.PHONEGAP.com Generating Android Project using CORDOVA Publishing to Google Play Store Mobile Web Apps development TRAINING The sample app published in Google Play Store jQueryMobile is a JavaScript + CSS framework born from jQuery. The best place to learn jQueryMobile is by accessing the official website at http://demos.jquerymobile.com/ As the na...

Developing Login Page with password verification

file 1 - login.php < html > < head > < title > Login Form </ title > </ head > < body > < strong > Login to MYCOMPANYHR system </ strong > < form name = "formlogin" method = "post" action = "verify.php" > < table width = "400" border = "0" > < tr > < td > Employee No </ td > < td >< input name = "EMPNO" type = "text" maxlength = "6" > Eg : 999999 </ td > </ tr > < tr > < td > Password </ td > < td >< input name = "PASSWORD" type = "password" ></ td > </ tr > < tr > < td >& nbsp ;</ td > < td >< input name = "submit" type = "submit" value = "Login" ></ td > </ tr > </ table > </ form > ...

Using Fling Motion Gesture in Android

The layout . I’m using the ViewFlipper to demonstrate this simple fling application. So, what is Fling… It’s also known as the swiping action on your mobile device screen. In this demo, I prepared an Activity with ViewFlipper layout that has 3 screens. Green, Blue and Yellow. <? xml version="1.0" encoding="utf-8" ?> < LinearLayout xmlns : android = "http://schemas.android.com/apk/res/android" android : orientation = "vertical" android : layout_width = "fill_parent" android : layout_height = "fill_parent" > < TableLayout android : id = "@+id/LinearLayout01" android : layout_width = "fill_parent" android : layout_height = "wrap_content" > < TableRow > < TextView android : id = "@+id/btnback" android : text = "Fling left - Back " android : layout_width = ...