欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

webView

程序员文章站 2022-04-19 23:05:52
...

设置

public class SecondActivity extends BaseActivity {

    WebView webview;

    @Override
    protected int conview() {
        return R.layout.activity_second;
    }

    @Override
    protected void initView() {
        webview = findViewById(R.id.webview);
        Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        webview.loadUrl(name);
        webview.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
                return super.shouldOverrideKeyEvent(view, event);
            }
        });


    }

    @Override
    protected void initData() {

    }
}

布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SecondActivity">

    <WebView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/webview"/>

</RelativeLayout>
相关标签: webview