Event Handling in Custom ListViews

Put your problem here if it does not fit any of the other categories.

Event Handling in Custom ListViews

Postby Legend » Tue Oct 13, 2009 3:28 pm

I am doing the following: Custom ListView with an ImageView and a TextView. I would like to perform different actions depending on whether an image or a text element was clicked. Now, there are two approaches I can take to perform event handling:

Approach #1: Attach an OnItemClick Listener to an item in the ListView and perform a suitable action.
Problem: It remains in question as to which element (image or text) was clicked. How would I determine this piece of information and then take the necessary action?

Approach #2: Attach an OnClick Listener to the image and text separately inside each listview item and then perform a suitable action.
Problem: I am highly skeptical about the performance of this approach. Added to that, when a click is performed, the row of the item is not being highlighted which makes it highly non-intuitive. How would I make the row highlight in this case?

Any suggestions?
Junior Developer
Junior Developer
Posts: 12
Joined: Tue Sep 29, 2009 1:04 am


Return to Other Coding-Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 7 guests