Search code examples
androidxmlandroid-buttonautolink

android:autoLink is not working in ButtonView in Android?


I have used autolink in ButtonView like below,

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

if I used string like below I am able to go to email,

<string name="mail"><a href = "[email protected]">[email protected]</a></string>

But If I do like below, not happening,

<string name="mail"><a href = "[email protected]">Send Mail</a></string>

That is the problemmm... but nothing happened on clicking button... When I used autolink for textView worked perfectly.. But why not working for Button???Thanks in advance


Solution

  • Solved my problem when doing like below,

    mailRedirectButton.setAutoLinkMask(0);
    String content="<a href =mailto:[email protected]>Send</a>";
            mailRedirectButton.setText(Html.fromHtml(content));
            mailRedirectButton.setMovementMethod(LinkMovementMethod.getInstance());
    

    Referred here https://stackoverflow.com/a/33709981/12273964

    Thank you for everyone who tried to help me..