0

我在 ButtonView 中使用了自动链接,如下所示,

 <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/email"
            android:autoLink="email"
            />

如果我使用像下面这样的字符串,我可以去电子邮件,

<string name="mail"><a href = "abc@gmail.com">abc@gmail.com</a></string>

但如果我喜欢下面,不会发生,

<string name="mail"><a href = "abc@gmail.com">Send Mail</a></string>

这就是问题...但是单击按钮时没有任何反应...当我使用自动链接进行 textView 工作时效果很好。但是为什么不为 Button 工作???提前谢谢

4

2 回答 2

0

在执行以下操作时解决了我的问题,

mailRedirectButton.setAutoLinkMask(0);
String content="<a href =mailto:abc@gmail.com>Send</a>";
        mailRedirectButton.setText(Html.fromHtml(content));
        mailRedirectButton.setMovementMethod(LinkMovementMethod.getInstance());

此处引用https://stackoverflow.com/a/33709981/12273964

感谢所有试图帮助我的人..

于 2020-07-16T10:33:03.873 回答
0

Hai Sandhiya 你可以使用 Linkify 类来实现你的需求。试试那个

于 2020-07-15T07:19:04.167 回答