Question

Does anyone have a good tutorial for implementing onItemClick() for a ListView populated by a custom ArrayAdapter?

I'm struggling with how Android is recycling views, and how to affect the layout of the selected view (which is a RelativeLayout). The way I've implemented it, I'm just doing a simple background colour change, but everytime I choose a row, when I scroll the ListView there are other off screen items selected too.

Any ideas?

Was it helpful?

Solution

Have a look to this answer. Custom code of ArrayAdapter.getView() (where view recycling is done) might be useful to you, I was trying to achieve something similar and it worked for me at last :)

OTHER TIPS

You can find lots of good examples of the custom Listview with Adapters.Some of the Examples are listed below:

(1)custom-listview-android

(2)android-custom-listview-with-image-and-text

(3)Custom Array Adapter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top