본문 바로가기
IT/Android

WebView / 웹 문서 / 웹 뷰

by Jeami 2013. 7. 16.
반응형

안드로이드



Project Name : HttpWebView

Activity : First.java

API version 10


웹뷰는 웹브라우저를 통해 웹사이트의 문서를 보여주는 역할입니다.

구글 메인페이지 소스가 가장 간단하기 때문에 구글로 연결하도록 하겠습니다.

아주 간단한 작업이니 오래 걸리지 않으실 겁니다^^



이 글이 도움이 되신다면 추천 한 방 부탁드려요~

양질의 정보로 보답하겠습니다



main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical"

    >

    <WebView

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:textSize="26dp"

        android:gravity="center"

        android:textColor="#ff0000"

        android:background="#00ff00"

        android:text="webview"

        android:id="@+id/webview" />

</LinearLayout>




HttpWebViewMainfest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.example.httpwebview"

    android:versionCode="1"

    android:versionName="1.0" >


    <uses-sdk

        android:minSdkVersion="10"

        android:targetSdkVersion="10" />

    <uses-permission android:name="android.permission.INTERNET"/>

    

    <application

        android:allowBackup="true"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >

        <activity

            android:name="com.example.httpwebview.First"

            android:label="@string/app_name" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>

</manifest>



First.java

package com.example.httpwebview

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.webkit.WebView;


public class First extends Activity {

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

WebView mWebView = (WebView)findViewById(R.id.webview);

//자바 스크립트도 보여주겠다.

mWebView.getSettings().setJavaScriptEnabled(true);

mWebView.loadUrl("http://www.google.com");

}//end

}//main END



strings.xml 은 굳이 따로 수정할 내용은 없습니다~

실행화면은 아래와 같습니다.




반응형

loading