1、主要布局
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent">
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 map = new HashMap() ;
map.put( webViewHeaderKey , webViewHeaderValue ) ;
webView.loadUrl( url , map ) ;
}else {
webView.loadUrl( url ) ;
}
}
}
https://www.cnblogs.com/zhaoyanjun/category/684868.html