I have a TextView with android:autoLink="email".
If I put my email address in there then a link appears that I can click.
How do I have different text appear (for example 'Send Feedback') instead of the email address but still behave the same when clicked?
Thanks
To achieve what I wanted required a different approach:
TextView feedback = (TextView) findViewById(R.id.TextViewSendFeedback); feedback.setText(Html.fromHtml("<a href=\"mailto:[email protected]\">Send Feedback</a>")); feedback.setMovementMethod(LinkMovementMethod.getInstance());
This basically places HTML in the TextView so I get a link saying 'Send Feedback' but clicking it opens the default email application.
Word of warning: Trying this in the emulator didn't initially work for me, saying it was unsupported. This was just because I didn't have an email account setup. Setting one up in the emulator made the link work as I wanted.
You can use both links and email if you set the following param in the TextView
android:autoLink="web|email"
the links will be opened in the browser and the mails will be sent by the default mail client
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With