第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

當(dāng)用戶單擊它時如何從 WebView 內(nèi)的鏈接提供 url

當(dāng)用戶單擊它時如何從 WebView 內(nèi)的鏈接提供 url

慕無忌1623718 2021-10-20 11:24:33
我有一個 WebView。它包含頁面,由 Jsoup 過濾。    WebView cntContent;    WebView cntComments;    WebSettings webSettingsContent;    WebSettings webSettingsComments;        cntContent = findViewById(R.id.cntContent);        cntComments = findViewById(R.id.cntComments);        webSettingsContent = cntContent.getSettings();        webSettingsComments = cntComments.getSettings();        webSettingsContent.setDefaultFontSize(16);        webSettingsComments.setDefaultFontSize(16);        cntContent.setBackgroundColor(Color.TRANSPARENT);        cntComments.setBackgroundColor(Color.TRANSPARENT);        webSettingsContent.setAppCacheEnabled(true);        webSettingsComments.setAppCacheEnabled(true);        cntContent.loadDataWithBaseURL(contentUrl, contentFinal, "text/html", "utf-8", null);        cntComments.loadDataWithBaseURL(contentUrl, commentsFinal, "text/html", "utf-8", null);        cntContent.setClickable(true);頁面包含鏈接。當(dāng)用戶單擊鏈接并將 url 放入字符串時,如何提供鏈接的 url?
查看完整描述

1 回答

?
慕慕森

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超17個贊

您應(yīng)該做的是為 WebView 提供您自己的 WebViewClient。子類化 WebViewClient 并使用 WebView 方法 setWebViewClient 對其進(jìn)行設(shè)置。然后在 WebViewClient 中覆蓋“shouldOverrideUrlLoading”方法并使用鏈接執(zhí)行任何您喜歡的操作。


WebView wv = new WebView();

 wv.setWebViewClient(new WebViewClient() {

            @Override

            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {

                String url = request.getUrl().toString();

                return false;

            }

        });


查看完整回答
反對 回復(fù) 2021-10-20
  • 1 回答
  • 0 關(guān)注
  • 146 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號