大家好我有一个listView,当你点击每个意图将开始意图工作是如此简单显示项目的网址,但当我点击项目直接到浏览器并显示当前网址 这是我的适配器点击代码
urlLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String url =twitch.getUrl();
Intent intent = new Intent(context,TwitchWebView.class);
intent.putExtra("url",url);
context.startActivity(intent);
}
});
这是webview活动代码
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_twitch_web_view);
wv = (WebView) findViewById(R.id.twitch_web_view);
Bundle bundle = getIntent().getExtras();
String url = bundle.getString("url");
if (url!= null){
Toast.makeText(this, url, Toast.LENGTH_SHORT).show();
wv.loadUrl(url);
}
我想在此webView上显示网址(关于Twitch.tv的网址)
答案 0 :(得分:1)
试试这个
wv.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return super.shouldOverrideUrlLoading(view, request);
}
});