Skip to content

Instantly share code, notes, and snippets.

@jebai
Created April 7, 2017 05:44
Show Gist options
  • Save jebai/3677f1467ddef70a476a153ff418d93b to your computer and use it in GitHub Desktop.
Save jebai/3677f1467ddef70a476a153ff418d93b to your computer and use it in GitHub Desktop.
package com.afcat.channel.webviewtest;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView)findViewById(R.id.webview);
TextView header = new TextView(this);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(-1, 300);
header.setText("1234566");
header.setBackgroundColor(Color.RED);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
});
// webView.addView(header, 0, params);
webView.addView(header, params);
webView.loadUrl("http://sdywcd.iteye.com/blog/2035458");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment