【发布时间】:2016-05-10 11:50:24
【问题描述】:
我有在应用程序中显示条款和条件的代码。在第一行我有一个链接。我希望在 webview 中加载该链接。
以下是片段代码:
String[] tncList = getResources().getStringArray(R.array.tnc_text_array);
for(int i=0;i < tncList.length;i++)
{
LinearLayout llItem=(LinearLayout)inflater.inflate(R.layout.terms_n_cond_fragment_layout, null);
TextView txt= (TextView)llItem.findViewById(R.id.tncText);
if(i == 0) {
txt.setText(Html.fromHtml(tncList[i]));
txt.setMovementMethod(LinkMovementMethod.getInstance());
} else {
txt.setText(tncList[i]);
}
tncTextLayout.addView(llItem);
}
以下是资源文件中的字符串数组:
<string-array name="tnc_text_array">
<item>Standard terms and condition apply To read click <![CDATA[<a href="example.com/termsandconditions">here</a>]]></item>
<item>lorem ipsum</item>
<item>lorem ispsum</item>
<item>lorem ipsum</item>
</string-array>
通过使用上面的代码生成链接,用户可以单击该链接并在浏览器中打开它,但它在移动视图中打开,但我希望它在桌面视图中打开。
我希望它在浏览器中打开,但在桌面视图或 web 视图中打开。
【问题讨论】:
-
在 xml 文本视图中使用 android:autoLink="all"
标签: android android-fragments android-intent webview android-resources