0

我在超链接中有一个文本视图,当我单击要打开警报对话框的链接时。如何做到这一点。我知道单独创建警报对话框,但使用超链接变得很困难。

我的代码

policy.setText(Html.fromHtml("<a href>PasswordPolicy</a> "));
4

2 回答 2

1

这涉及到一个小技巧,在 strings.xml 中使用下划线标记,如下所示

 <string name="tvideo"><u>Video</u></string>

现在在 .xml 的 TextView 中设置它

并 setonclicklistener 到那个 TextView 并打开你的对话框。

另请注意,将在运行时看到输出。恐怕它在图形布局中不可见。

于 2013-10-09T11:45:31.323 回答
0

为此,您需要创建自定义对话框及其文本属性作为链接。

TextView myWebSite = new TextView(this);
myWebSite .setText("http://http://www.google.com/");
Linkify.addLinks(myWebSite , Linkify.WEB_URLS);
于 2013-10-09T11:51:09.713 回答