Skip to content

Instantly share code, notes, and snippets.

@liposo
Created June 27, 2018 19:52
Show Gist options
  • Save liposo/ddfb50f98967c9cd4c25d0d78acc6fe0 to your computer and use it in GitHub Desktop.
Save liposo/ddfb50f98967c9cd4c25d0d78acc6fe0 to your computer and use it in GitHub Desktop.
Get urls from text and make then clickable (Android)
final List<String> extractedUrls = TextLink.extractUrls(imovel.descricao);
if (extractedUrls.size() > 0) {
for (final String link : extractedUrls) {
ClickableSpan normalLinkClickSpan = new ClickableSpan() {
@Override
public void onClick(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link));
startActivity(browserIntent);
}
};
TextLink.makeLink(txtViewDescricao, link, normalLinkClickSpan);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment