Capturing TextView clicks in ListView

I’ve a custom ListView containing 4 TextViews. Now, the TextViews have to be Linkifiable. Since Linkify wasn’t working in ListView, I made a callIntent function to see if the link is clickable or not. But if there’s no clickable link, I want to start a new Activity. I use the following code:

           lvMembersList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {

          final TextView txtLine1 = (TextView) arg1.findViewById(;
          final TextView txtLine2 = (TextView) arg1.findViewById(;
          final TextView txtLine3 = (TextView) arg1.findViewById(;
          final TextView txtLine4 = (TextView) arg1.findViewById(;

         txtLine1.setOnClickListener(new OnClickListener() {
                              public void onClick(View v) {

         txtLine2.setOnClickListener(new OnClickListener() {
                              public void onClick(View v) {

         txtLine3.setOnClickListener(new OnClickListener() {
                              public void onClick(View v) {

         txtLine4.setOnClickListener(new OnClickListener() {
                              public void onClick(View v) {


Now, when I click on an item for the first time, the TextView listeners are getting set. The individual clicks only works after the second time. What should I do in such a case?


Put this code in the getView() method in the adapter. And in your code onItemClick is called when you click on a row of the listview.

Need Your Help

DOA pattern without dependency injection

java-ee junit dependency-injection dao factory-pattern

In our company we use DAO pattern in almost every project. This has some pros and cons but the question is not about that. We just started another project but in comparison with the others it is very

How do I tell all my AWS EC2 instances to pull from git / codecommit?

git amazon-web-services amazon-ec2 aws-codecommit

I am using AWS CodeCommit which seems to be like a stripped down version of git.

How do you get Matlab to write the BOM (byte order markers) for UTF-16 text files?

java matlab file-io unicode utf-16

I am creating UTF16 text files with Matlab, which I am later reading in using Java. In Matlab, I open a file called fileName and write to it as follows:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.