Android培训三十二课之网页框

本文介绍了Android中WebView组件的基本用法,通过示例代码展示了如何加载HTML内容并显示在应用内。适合初学者快速掌握WebView的基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

         Android是一种以嵌入式为基础的开放源码操作系统,Android培训 第三课:系统空间运用。 系统控件简单的有:多项选择,单项选择,Menu菜单.......这里我只是讲解一下其中的网页框,如果想了解其他内容,可以登录——》http://www.akaedu.org/pages/about04.php
       
      

代码如下:

  1. public class WebViewActivity extends Activity {
  2.     WebView webView = null;
  3.     static final String MIME_TYPE = "text/html";
  4.     static final String ENCODING = "utf-8";
  5.    
  6.    
  7.     @Override
  8.     protected void onCreate(Bundle savedInstanceState) {
  9.         setContentView(R.layout.webview);
  10.        
  11.         webView = (WebView) findViewById(R.id.webview);
  12.         webView.loadDataWithBaseURL(null,"<a href='http://blog.youkuaiyun.com/xys289187120'>欢迎访问雨松MOMO的博客</a>", MIME_TYPE, ENCODING, null);
  13.         super.onCreate(savedInstanceState);
  14.     }
  15. }
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.         android:id="@+id/textviewll"
  4.         android:orientation="vertical" android:layout_width="fill_parent"
  5.         android:layout_height="fill_parent">
  6.                 <TextView android:layout_width="fill_parent"
  7.                           android:layout_height="wrap_content"
  8.                           android:textColor="#000000"
  9.                           android:textSize="18dip"
  10.                           android:background="#00FF00"
  11.                       android:text="网页框WebView测试"
  12.                       android:gravity="center_vertical|center_horizontal"
  13.                       />
  14.         <WebView android:id="@+id/webview"
  15.                     android:layout_height="wrap_content"
  16.                     android:layout_width="fill_parent"/>
  17. </LinearLayout>

大笑更多精彩——》

 

 Android培训三十二课程之第一课

Android培训三十二课程之第二课

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值