我的对话框未触发webviews onclicklistener

时间:2019-05-10 16:11:43

标签: android webview onclicklistener

在我的对话框的Web视图中单击时,没有任何反应。

对此有任何建议/帮助吗?

这是我的代码:

dialog = new Dialog(context);
dialog.setContentView(R.layout.quicktextviewerlayout);

webView = dialog.findViewById(R.id.mywebview);
webView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);

setWebViewTextSize();

webView.loadData("No Text", "text/html", "utf-8");
webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
some stuff here
    }
});
webView.setBackgroundColor(Color.WHITE);

ImageView imageView = dialog.findViewById(R.id.closebutton);
imageView.getLayoutParams().width = Layouts.getPixelPerCm()/3;
imageView.getLayoutParams().height = Layouts.getPixelPerCm()/3;
imageView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        dialog.dismiss(); <- works fine here.
    }
});

webView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // TODO : isnt triggered !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        interactActivity.openBookFromQuickTextViewerState();
    }
});

0 个答案:

没有答案