gpt4 book ai didi

android - 没有 url 的 TextView 上的超链接未显示且不可单击

转载 作者:行者123 更新时间:2023-11-29 01:57:50 24 4
gpt4 key购买 nike

我想在 textview 上显示 hyperLinke 而不是在 url 上,例如:嗨,“url”怎么样。(这里的 url 将打开 www.google.com)。所有这些都将出现在警报对话框中..

我遵循了以下方法,但没有得到正确的解决方案..

String.xml---
谷歌

        String str = getResources().getString(R.string.link);
final TextView txtvw = new TextView(this);
txtvw.setText(Html.fromHtml(str));
txtvw.setClickable(true);
txtvw.setAutoLinkMask(RESULT_OK);
txtvw.setMovementMethod(LinkMovementMethod.getInstance());
Linkify.addLinks(txtvw, Linkify.WEB_URLS);

AlertDialog.Builder alt_bld = new AlertDialog.Builder(context);
alt_bld.setTitle(title);

alt_bld.setCancelable(false);

alt_bld.create();
alt_bld.setView(txtvw).show();

最佳答案

使用 CDATA 标签:

<string name="link"><![CDATA[ <a href="http://www.google.co.in">Google</a> ]]></string>

更新:

String str = getResources().getString(R.string.link);
final TextView txtvw = new TextView(this);
txtvw.setText(Html.fromHtml(str));
txtvw.setMovementMethod(LinkMovementMethod.getInstance());

new AlertDialog.Builder(context)
.setTitle(title)
.setCancelable(false)
.setView(txtvw)
.show();

关于android - 没有 url 的 TextView 上的超链接未显示且不可单击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14213184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com