Using WebView to load url : WebView « UI « Android






Using WebView to load url

   
/***
  Copyright (c) 2008-2009 CommonsWare, LLC
  
  Licensed under the Apache License, Version 2.0 (the "License"); you may
  not use this file except in compliance with the License. You may obtain
  a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

package com.commonsware.android.browser1;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class BrowserDemo1 extends Activity {
  WebView browser;
  
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.main);
    browser=(WebView)findViewById(R.id.webkit);
    
    browser.loadUrl("http://commonsware.com");
  }
}


//res\layout\main.xml
<?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"
  >
  <WebView android:id="@+id/webkit"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
  />
</LinearLayout>

   
    
    
  








Related examples in the same category

1.Adding WebView to Activity, load URL and grab focus
2.Load local resource into WebView
3.Enable Javascript for WebView
4.Load remote web page for WebView
5.extends WebViewClient and check the url
6.Using WebView to load static html string
7.Load static html file into WebView
8.Load Url to WebView
9.Load image from remote host to WebView
10.Add a client to the web view
11.Sample creating 10 webviews.