Chait
Chait

Reputation: 677

List Items postion click on each row issue in android

I have a list of items in Listview. In each row, I have Text and image. Currently, the click effect is there for the entire row. I want to add a specific click effect to text view and image.

How to do that?

Upvotes: 0

Views: 51

Answers (1)

Ollie Strevel
Ollie Strevel

Reputation: 871

I guess you have a custom adapter for your listview... so if you override the getView method, there you can set the onclick listener for each of your views.

image.setOnClickListener(new OnClickListener() 
{
    @Override
     public void onClick()
     { 
         // Do something
     } 
});

and

text.setOnClickListener(new OnClickListener() 
    {
        @Override
         public void onClick()
         { 
             // Do something
         } 
    });

Now, Doyou want the same listener defined in onItemClickListener in each of your views? easy: you can define your performance in another method, and only call it where you want.

I hope this help

Upvotes: 1

Related Questions