18002

Links and text in listview item

Question:

I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact: - on click on a link the link is visually selected (blue selector) and will open up in the browser - on click on normal text the whole list item is selected

The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible). I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.

So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?

Thanks! :)

Answer1:

if you have email id in textview use below code..

TextView email = (TextView)findViewById(R.id.TextView04); email.setText("sasd asd@gmai.com sadasd"); email.setLinkTextColor(Color.WHITE); Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);

if you have url in textview use below code...

TextView tv = (TextView)findViewById(R.id.TextView04); tv.setText("sasd https://asd.com sadasd"); tv.setLinkTextColor(Color.WHITE); Linkify.addLinks(tv,Linkify.WEB_URLS);

Recommend

  • android textview click on a link
  • Spellchecker is not working in tinymce 4.0 (Non JSON response)
  • TinyMCE multiple editors not rendering correctly in Yii2
  • NHibernate - Paging with ICriteria and optional ICriteria calls
  • How to adapt DirectX-style world/view/projection matrices to OpenGL?
  • how to add Image in JPanel
  • Sorting Custom Listview Items Using Spinner Android
  • How to escape xpath in php
  • Do iTunesConnect external testers get updates for *every* uploaded ipa file after Beta Approval?
  • Corda: How to implement hierarchical relationships between state data persisted to H2
  • Why am I getting an Argument exception when creating event handler dynamically?
  • Disabling swipe gesture in Windows Phone 8.1 pivot control
  • Write to elasticsearch from spark is very slow
  • Exclude Classes from Being Included in Shaded Jar
  • Allowing audio files in Spring MVC 3.0?
  • Windows biometric framework sample umdf driver: This device cannot start. (Code 10)
  • What does “T extends Junk” mean in a generic class in Java?
  • Facebook Error (#200) The user hasn't authorized the application to perform this action (PHP)
  • How to load dynamic images in custom ListView
  • What is the difference between dynamically creating a script tag and statically embed a script tag?
  • How do I use libcurl to printf a remote FTP directory listing?
  • Multiplying polynomials/simplifying like terms
  • using maven pom while creating jar:test-jar some times it says JAR will be empty - no content was ma
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How to clear a browser cache in Protractor
  • Cloud Code: Creating a Parse.File from URL
  • Can a PHP script be scheduled to run at a specific time or after a specific amount of time has expir
  • How to encrypt Connectionstring written in web.config from codebehind?
  • Can someone explain this Java code (formatting the output using System.out.format) to me?
  • Codeigniniter insert data through models and controller
  • Sign a Pdf using custom digital signature in Java
  • Running R's aov() mixed effects model from Python using rpy2
  • What does the “id” field in an Android “Google Play Music” broadcast intent correspond to?
  • How to mutate multiple variables without repeating codes?
  • ReferenceError: TextEncoder is not defined
  • JavaScript RegExp Replace
  • XSLT Transformation to validate rules in XML document