小视频源码,Android内嵌H5页面展示的相关代码
主要是使用WebView控件
//布局
xmlns:app="
xmlns:tools="
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".WebViewActivity">
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
//使用
final WebView webView = findViewById(R.id.webview);
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { //设置在当前页面加载h5页面,不启动浏览器
view.loadUrl(url);
return true;
}
});
chromeClient = new WebChromeClient(){
@Override
public void onProgressChanged(WebView view, int newProgress) { //加载进度
super.onProgressChanged(view, newProgress);
Log.e("MainActivity", "progress:::::"+newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) { //标题修改
super.onReceivedTitle(view, title);
Log.e("MainActivity", "title:::::"+title);
}
};
webView.setWebChromeClient(chromeClient);
webView.loadUrl(");
findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chromeClient.onReceivedTitle(webView,"title");//修改标题
}
});
以上就是
小视频源码,Android内嵌H5页面展示的相关代码, 更多内容欢迎关注之后的文章