在我的JsonParsing中,我从这个json获得了URL。我需要在网络视图中显示该网址链接。我该怎么办?
代码在这里:
TextView tv = (TextView)findViewById(R.id.textView1);
Bundle bundle = new Bundle();
bundle = getIntent().getExtras();
String id = bundle .getString("id");
String firstName = bundle.getString("firstName");
String lastName = bundle.getString("lastName");
String headline = bundle.getString("headline");
String pictureUrl = bundle.getString("pictureUrl");
String url = bundle.getString("url");
Log.v("LV","id :"+id+"\n"+"firstname :"+firstName+"\n"+"lastname :"+lastName+"\n"+"headline :"+headline+"\n"+"pictureUrl :"+pictureUrl+"\n"+"siteStandardProfileRequest"+url);
tv.setText("id :"+id+"\n"+"firstname :"+firstName+"\n"+"lastname :"+lastName+"\n"+"headline :"+headline+"\n"+"pictureUrl :"+pictureUrl+"\n"+"Profile URL :"+url);
因为您要求在webview中打开url,所以您必须在项目中使用一个webview并这样做
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
// you need to setWebViewClient for forcefully open in your webview
webview.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
其他方法是(这将在网络浏览器中打开)
Intent browserIntent = new Intent(Intent.ACTION_VIEW,uri.parse(url));
startActivity(browserIntent);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句