<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      安卓筆記俠

      專注安卓開發

      導航

      Java調用JavaScript

      1.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"  
          >  
          <TextView    
              android:layout_width="fill_parent"   
              android:layout_height="wrap_content"   
              android:text="Welcome to Mr Wei's Blog."  
              />  
          <WebView  
              android:id="@+id/webview"  
              android:layout_width="fill_parent"   
              android:layout_height="wrap_content"   
          />  
          <Button  
              android:id="@+id/button"  
              android:layout_width="fill_parent"  
              android:layout_height="wrap_content"  
              android:text="Change the webview content"  
          />  
      </LinearLayout> 
      

      2.demo.html

      <html>  
          <mce:script language="javascript"><!--  
         
              function fillContent(){  
                  document.getElementById("content").innerHTML =   
                       "This Content is showed by Android invoke Javascript function.";  
              }  
            
      // --></mce:script>    
        <body>  
          <p><a onClick="window.demo.startMap()" href="">Start GoogleMap</a></p>  
          <p id="content"></p>  
          <p>A Demo ----Android and Javascript invoke each other.</p>  
          <p>Author:Frankiewei</p>  
        </body>  
      </html>
      

      3.WebViewDemo.java

      package com.tutor.webwiewdemo;
      import android.app.Activity;
      import android.content.ComponentName;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.View;
      import android.webkit.WebSettings;
      import android.webkit.WebView;
      import android.widget.Button;
      public class WebViewDemo extends Activity {
      	private WebView mWebView;
      	private Button mButton;
      	public void onCreate(Bundle savedInstanceState) {
      		super.onCreate(savedInstanceState);
      		setContentView(R.layout.main);
      		setupViews();
      	}
      	//初始化
      	private void setupViews() {
      		mWebView = (WebView) findViewById(R.id.webview);
      		WebSettings mWebSettings = mWebView.getSettings();
      		//加上這句話才能使用javascript方法
      		mWebSettings.setJavaScriptEnabled(true);
      		//增加接口方法,讓html頁面調用
      		mWebView.addJavascriptInterface(new Object() {
      			//這里我定義了一個打開地圖應用的方法
      			public void startMap() {
      				Intent mIntent = new Intent();
      				ComponentName component = new ComponentName(
      						"com.google.android.apps.maps",
      						"com.google.android.maps.MapsActivity");
      				mIntent.setComponent(component);
      				startActivity(mIntent);
      			}
      		}, "demo");
      		//加載頁面
      		mWebView.loadUrl("file:///android_asset/demo.html");
      		mButton = (Button) findViewById(R.id.button);
      		//給button添加事件響應,執行JavaScript的fillContent()方法
      		mButton.setOnClickListener(new Button.OnClickListener() {
      			public void onClick(View v) {
      				mWebView.loadUrl("javascript:fillContent()");
      			}
      		});
      	}
      }
      

        

                 

                    首界面                                               點擊按鈕時,html內容改變

       

        

        

      posted on 2016-10-23 17:00  安卓筆記俠  閱讀(733)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 99久re热视频这里只有精品6| 国产精品无码一区二区三区电影 | 亚洲日韩乱码中文无码蜜桃| 国产剧情视频一区二区麻豆| 影音先锋AV成人资源站在线播放| 郯城县| 欧美黑人巨大xxxxx| 狠狠久久五月综合色和啪| 露脸一二三区国语对白| 皮山县| 国产精品日韩中文字幕| 熟女系列丰满熟妇AV| 欧美人与zoxxxx另类| 人妻中文字幕亚洲精品| 丁香婷婷在线观看| 高清破外女出血AV毛片| 亚洲精品色在线网站| 免费无码又爽又刺激成人| 亚洲精品中文字幕第一页| 亚洲精品天堂成人片AV在线播放| 蜜臀av无码一区二区三区| 国产亚洲精品在av| 国产亚洲欧美在线观看三区| 无码中文字幕人妻在线一区二区三区| 白白发布视频一区二区视频| 国产精品中文一区二区| 日韩少妇内射免费播放| 插入中文字幕在线一区二区三区| 国产精品爆乳奶水无码视频免费| 狠狠噜天天噜日日噜| 国产精品大片中文字幕| 国产精品免费无遮挡无码永久视频| 国产伦码精品一区二区| 久久久亚洲精品无码| 欧美又黄又大又爽a片三年片 | 强奷漂亮雪白丰满少妇av| 久久国产成人av蜜臀| 国产午夜福利片在线观看| 一区二区免费高清观看国产丝瓜| 视频一区二区三区四区不卡| 日韩黄色av一区二区三区|