Thursday, March 15, 2012

[android-developers] Are there drawbacks to implementing onClickListener for each ListView row instead of onItemClickListener?

Also posted on Stack Overflow.

It would be more convenient for me to register a unique onClickListener for each row in the ListView, but I want to be sure that this is an acceptable practice.

The reason for this is that I have multiple classes of rows in the ListView. Each class has a completely different responsibility and behavior. For example, consider a ListView that can contain both sub-categories and book titles. If a book title is clicked, a new activity should start that shows the cover image. If a sub-category is clicked, a new list of books and categories is displayed.

I'd like the row itself to maintain knowledge about its own identity and responsibility rather than having to leak the knowledge about each row to be maintained by the implementer of onItemClickListener.

I'd also like to know what the performance implications are of doing this vs. implementing my own logic to figure out how to handle the click.

Are there drawbacks to implementing onClickListener for each ListView ArrayAdapter row instead of onItemClickListener?  I'm looking for  concrete data and specific drawbacks rather than vague recommendations.

Should I expect memory use, initialization time, or steady-state speed (like scrolling through the list) to be significantly affected?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment