歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android--在程序裡浏覽網頁/Webview的使用

Android--在程序裡浏覽網頁/Webview的使用

日期:2017/3/1 10:01:50   编辑:Linux編程

在說明Android--在程序裡浏覽網頁/Webview的使用實例之前,首先給出程序的運行截圖:

在程序中需要一個Webview控件用於顯示網頁,下方的兩個按鈕一個是回到前一頁,一個是去往下一頁,保存在混村中。

下面給出程序的實現代碼:

1.布局文件

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"

android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<!-- 建立一個EditText -->
<!-- 建立一個ImageButton -->
<!-- 建立一個WebView -->

<EditText
android:id="@+id/myEditText1"
android:layout_width="267px"
android:layout_height="60px"
android:layout_x="13dp"
android:layout_y="38dp"
android:ems="10"
android:textSize="18sp" />

<ImageButton
android:id="@+id/myImageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="206dp"
android:layout_y="38dp"
android:background="@drawable/white"
android:src="@drawable/go" />

<WebView
android:id="@+id/myWebView1"
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_x="0dp"
android:layout_y="79dp"
android:background="@drawable/black"
android:focusable="false" />

<Button
android:id="@+id/buttonback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="38dp"
android:layout_y="426dp"
android:text="Back " />

<Button
android:id="@+id/buttonfoward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="179dp"
android:layout_y="426dp"
android:text="Forward" />

</AbsoluteLayout>

Copyright © Linux教程網 All Rights Reserved