2013-07-13 86 views
0

我想打开http://www.google.com时点击到textview链接。但它启动浏览器,但在地址栏显示wwww.google.com%27,它会产生错误。请提供解决方案。在textView链接中打开网站

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main); 
    TextView textView=(TextView)findViewById(R.id.textView1); 
    textView.setClickable(true); 
    textView.setMovementMethod(LinkMovementMethod.getInstance()); 
    String text="<a 'href=http://www.google.com'> Click to open Google!!! </a>"; 
    textView.setText(Html.fromHtml(text)); 

回答

0

尝试使用HTML编码通过代码设置文本/解码文本

Html.fromHtml(string) 
+0

嗨我是初学者,不知道如何对文本进行编码/解码。您能否解释 – user2478122

+0

尝试类似这样的'Html.fromHtml(“<![CDATA [ Click to open Google!!!]]>”);' –

+0

我在www.google.com上删除了撇号,现在可以使用了。 – user2478122

0

尝试,

机器人:linkify = “网络” 在XML格式的TextView元素。这将打开浏览器。

相关问题