首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从文本视图单击未在浏览器中打开的锚定标签

从文本视图单击未在浏览器中打开的锚定标签
EN

Stack Overflow用户
提问于 2017-10-16 21:19:18
回答 1查看 269关注 0票数 0

使用这个字符串:

代码语言:javascript
复制
String stringConvertor="We are looking for talented individuals who share our values and <a href='http://www.precipeace.com/about/' target='_blank'>mission</a>.  What is your motivation for joining our company?","quesNo":1,"__v":0,"isDelete":false,"createdAt":"2017-08-16T11:51:05.644Z"},{"_id":"599431be8eedf235d9965a08","question":"Currently, we utilize coaching techniques like CBT, positive psychology, and other solution focused techniques to help our clients. <br class='breakclass'/><br class='breakclass'/> Are you familiar and capable of utilizing these techniques or open to learning about them?  What other techniques do you have experience with that you feel would benefit your future clients?"

代码:

代码语言:javascript
复制
<TextView
      android:id="@+id/txt_screening_question"
      android:layout_width="match_parent"
      android:gravity="center"
      android:layout_height="wrap_content"
      android:paddingBottom="@dimen/text_size_medium"
      android:textSize="@dimen/text_size_medium"
      android:autoLink="web"
      android:linksClickable="true"
      android:text="We are looking for talented individuals who share our values and mission. What is your motivation for joining our company?"
      android:textColor="@color/colorGrey"/>

Java代码:

代码语言:javascript
复制
Linkify.addLinks(txtScreeningQuestion, Linkify.WEB_URLS);
txtScreeningQuestion.setText(Html.fromHtml(stringConvertor));

给我提供解决方案如何点击它请给我任何解决方案如何点击锚标签串

EN

回答 1

Stack Overflow用户

发布于 2017-10-16 21:30:29

尝试以以下格式将字符串保存在strings.xml中。

代码语言:javascript
复制
<string name="welcome">
<![CDATA[ Welcome to <a href=\'http://www.google.com\'>Google</a>.]]>
</string>

然后将字符串分配给您的TextView,如下所示:

代码语言:javascript
复制
 Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(getString(R.string.welcome)));
            PackageManager manager = getPackageManager();
            List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);

            if (infos.size() > 0) {
                //At least one application can handle your intent
                //Put this code in onCreate and only Linkify the TextView from here
                //instead of using android:autoLink="web" in xml
                Linkify.addLinks(txtScreeningQuestion, Linkify.ALL);
                // or tvTextView.setAutoLinkMask(Linkify.WEB_URL), 
            }
    txtScreeningQuestion.setText(Html.fromHtml(getString(R.string.welcome));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46771356

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档