生成器中的builder(android.content.context)无法应用于Activity

时间:2015-10-28 04:58:30

标签: android

我试图在webview中加载网页。在Dialog.i中加载了webview,我尝试了这段代码。但是显示错误builder (android.content.context) in builder cannot be applied to ..并在this下划线红线。

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    webview=(WebView)findViewById(R.id.webview);
    webview.setWebViewClient(new WebViewClient();
    webview.loadUrl("http://example.com/abc.html");
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setView(webview);
    dialog.setPositiveButton("Okay", null);
    dialog.show();
}

1 个答案:

答案 0 :(得分:0)

试试这个>

{{1}}

检查此 - > android: webview inside dialog or popup