[英]Equivalent of html img src in android
我在Android布局中顯示鏈接,如下所示:
<TextView
android:id="@+id/linkable_text”
android:layout_width="match_parent"
android:layout_height="match_parent"
android:autoLink="web"
/>
我也這樣做: text.setMovementMethod(LinkMovementMethod.getInstance());
此方法有效,但我想導航到與TextView中顯示的URL不同的URL(我將其動態添加)。
我的意思是用戶界面中的鏈接顯示為: file.html
但是當我按下鏈接時,我想導航至以下網址: http://IP/path/file.html
我如何做到這一點而不必在TextView中顯示整個URL
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));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.