您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> 安卓开发 >> 正文

安卓网页框WebView设置方法

作者:佚名    责任编辑:admin    更新时间:2022-06-22

大家知道安卓网页框WebView设置吗?下面我们就给大家详细介绍一下吧!

  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.csdn.net/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>
复制代码

相信大家已经学会安卓网页框WebView设置了吧!感谢大家对我们网站的支持!

相关推荐:

安卓builder设置对话框的方法