Android 显示 WebView ,加载URL 时,向webview的 header 里面传递参数
2015-11-19 16:02
537 查看
1、主要布局
2、代码实现
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".MainActivity"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="match_parent"> </WebView> </RelativeLayout>
2、代码实现
package com.webview.demo; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.webkit.WebView; import java.util.HashMap; import java.util.Map; public class MainActivity extends AppCompatActivity { private WebView webView ; private String webViewHeaderKey = "tokenId" ; private String webViewHeaderValue = "562142" ; private String url = "" ; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); webView = (WebView) findViewById( R.id.webview ); if ( webViewHeaderValue != "" ){ Map<String, String > map = new HashMap<String, String>() ; map.put( webViewHeaderKey , webViewHeaderValue ) ; webView.loadUrl( url , map ) ; }else { webView.loadUrl( url ) ; } } }
相关文章推荐
- Android修改状态栏颜色 布局错乱问题解决
- Android CrashHandler使用时存在多个Log文件问题
- iOS SDK 集成指南
- 把网页加载进安卓显示,及其android系统webview控件使用详解
- iOS开发之MD5封装及应用
- Android 使用Fragment,ViewPagerIndicator 开发APP项目的主框架
- iOS设置同一个Label的不同颜色的字体
- android Graphics
- warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future
- Android音频系统之AudioFlinger(二)
- Ubuntu搭建Android开发环境
- android 新手错误
- Android官方提供的支持不同屏幕大小的全部方法(转)
- Mac安装非app store下载的软件
- android canvas.drawText()的研究
- iOS 9 适配中出现的坑
- webView 显示一段 html 代码
- iOS检测耳机插入拔出
- 【转】ios开发之生成所缩略图方式
- android第三方接入(QQ、微信、新浪微博和百度)