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

Finding a Model with Params other than ID

ruby-on-rails ruby ruby-on-rails-4 active-directory strong-parameters

I'm using Rails 4 with strong parameters to try to find a user by a parameter called "provider_id".

Dynamic import programatically

java dynamic import package classloader

I simply want to implement that line programatically in runtime.

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.