How to auto display website by the WebView?

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

How to auto display website by the WebView?

Postby WynixToo » Fri Jul 23, 2010 11:35 am

Hi,

i have doing a project which the application can browser the website by TabActivity. i have successful to access the website fromhttp://developer.android.com/guide/tutorials/views/hello-webview.html.

The problem is when it successful access the website, it didn't show out the page. And i need click other tab and change back to the here then the website only display.

1: May i know how to program it will auto show out the web page when the application successful access it?
2: how i can i know the website was successful access?
3: How can i control the progress dialog when the application loading the website?

Thank you very much

P/S: I'm sorry my english grammer no very well, hope you guys understand what i'm talking about
Thanks again~ :)


regard
Wynix
WynixToo
Junior Developer
Junior Developer
 
Posts: 16
Joined: Fri Jul 02, 2010 10:36 am
Location: Malaysia

Top

Re: How to auto display website by the WebView?

Postby WynixToo » Tue Jul 27, 2010 9:39 am

Hi,

I have asking my senior and found it the problem of the app didn't display the website because the repaint problem. but we have google before and didn't find any solution. do u guy face this kind of problem also??

here's my my xml code:

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:orientation="vertical">
     
     <WebView
        android:id="@+id/webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />
</LinearLayout>


and my wap code:

Code: Select all
package com.Testing.Wap;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView;

public class Wap_Tab extends Activity {
   
   WebView webview;
   ProgressDialog myProgressDialog = null;
   boolean loading = true;
   String url ="http://www.anddev.org";
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
       
        setContentView(R.layout.wap);
        myProgressDialog = ProgressDialog.show(Wap_Tab.this,
                    "Please wait...", "Opening Wap...", true);
         
        new Thread(){
           public void run(){
               try{
                  myProgressDialog.setMessage("Opening Wap.....");
                  webview = (WebView)findViewById(R.id.webview);
                  webview.getSettings().setJavaScriptEnabled(true);
                  webview.loadUrl(url);
                  sleep(5000);
                  myProgressDialog.dismiss();
               }catch (Exception e) {
                  e.printStackTrace();
               }      
              }
        }.start();
    } 
}


P/S: sorry about my bad english, hope u guy understand what i'm talking about.
Thank you very much :)

Regard
Wynix
WynixToo
Junior Developer
Junior Developer
 
Posts: 16
Joined: Fri Jul 02, 2010 10:36 am
Location: Malaysia

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests