gpt4 book ai didi

android - 如何在 webview 中打开 twitter hash 标签链接?

转载 作者:太空狗 更新时间:2023-10-29 13:37:26 25 4
gpt4 key购买 nike

我正在制作一个 android 应用程序,我必须在其中显示 twitter 的哈希标签链接但是当我在我们的自定义 webview 中加载它时,它将在默认浏览器中打开。你能帮我如何在 web View 中打开它吗?然后在默认浏览器中?

链接是:https://mobile.twitter.com/search/%23nokia

谢谢...

    WebViewClient yourWebClient = new WebViewClient()
{
/* Override page so it's load on my view only */
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// This line we let me load only pages inside Firstdroid Webpage
if ( url.contains("firstdroid") == true )
/* Load new URL Don't override URL Link */
return false;

// Return true to override url loading (In this case do nothing).
return true;
}
};


// Get Web view
mWebView = (WebView) findViewById( R.id.WebView ); //This is the id you gave
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setSupportZoom(true); //Zoom Control on web (You don't need this
//if ROM supports Multi-Touch
mWebView.getSettings().setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM
mWebView.setWebViewClient(yourWebClient);

// Load URL
Log.v("", ""+web2);
mWebView.loadUrl(web2);
btn.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Log.v("", "EXECUTED");
//website.this.finish();
Intent ii = new Intent(getParent(), Socialsites.class);
TabGroupActivity parentActivity3 = (TabGroupActivity)getParent();



// ii.putExtra("WEB", six.get(arg2));





parentActivity3.startChildActivity("bb", ii);
}

});

最佳答案

在 shouldOverrideUrlLoading() 中写 load.loadUrl(url) 为:

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}

关于android - 如何在 webview 中打开 twitter hash 标签链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9155440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com