问题描述
我有这块code:
TextView noteView = (TextView) view.findViewById(R.id.content);
noteView.setMovementMethod(LinkMovementMethod.getInstance());
noteView.setText(Html.fromHtml(noteView.getText().toString()));
我需要在web视图中打开链接,而不是在一个浏览器...这可能吗?我该怎么办?
I need to open links in a webview, not in a browser... is this possible?? how can I do??
在此先感谢。
推荐答案
是的,你可以做到这一点,这是pretty的简单,WebView功能的任务,你需要声明的对象和覆盖公共布尔shouldOverrideUrlLoading(web视图查看,字符串URL)
方法,在那里,你可以过滤网址或给一些自定义的功能。
Yes, you can do that, it's pretty simple task with WebView, you need to declare a WebViewClient object and override the public boolean shouldOverrideUrlLoading (WebView view, String url)
method, there you can filter urls or give some customized functionality.
在你的情况下,留在web视图,您将需要返回false上的方法。
In your case, to stay on the WebView, you would need to return false on that method.
查看本教程。
问候
编辑:的
看来你的问题是如何处理的TextView的URL中的单击事件。由于它的建议在这个问题上可以筛选 ACTION_VIEW
您的WebView包含活动的意图。如果您需要更多关于意图过滤器的指导,检查了这一点
It seems your question is how to handle the click event on the TextView's url. As it's suggested on this question you can filter the ACTION_VIEW
intent on your WebView containing Activity. If you need more guidance about intent-filters, check this out.
这篇关于在web视图,而不是默认的浏览器打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!