2015-04-02 65 views
0

我显示如下在Android布局的链接HTML IMG SRC的:相当于Android的

<TextView 
       android:id="@+id/linkable_text” 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:autoLink="web" 
       /> 

我也做:text.setMovementMethod(LinkMovementMethod.getInstance());

这工作,但我想导航到不同的URL比在我的TextView中显示的那个(我动态地添加它)。
我指的是在用户界面的链接显示:file.html但是当我按下链接,我想转到像一个网址:http://IP/path/file.html
我如何能做到这一点,而无需显示整个URL在我的TextView

+0

你的标题有点混乱。你可以删除* Img *部分,因为我不是它适当地定义你的问题。 – Beggs 2015-04-02 11:19:34

回答

1
Try this, and let me know what happen.. 

TextView textView =(TextView)findViewById(R.id.textView); 

textView.setClickable(true); 

textView.setMovementMethod(LinkMovementMethod.getInstance()); 
String text = "<a href='http://www.google.com'> Google </a>"; 
textView.setText(Html.fromHtml(text)); 
+0

作品!有没有办法显示光标越过链接时显示的小手? – Jim 2015-04-02 11:31:38