0

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?

biegleux
  • 13,179
  • 11
  • 45
  • 52
stephen mc
  • 751
  • 2
  • 12
  • 22

2 Answers2

0

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 :)

Community
  • 1
  • 1
jelies
  • 9,110
  • 5
  • 50
  • 65
  • Good answer! Can you post (or send me) your onItemClick for setting the Event to "checked"? I just want to see how it compares to mine. Thanks – stephen mc Jul 30 '12 at 08:57
0

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

AkashG
  • 7,868
  • 3
  • 28
  • 43
  • Cheers for that. I'll take a look at those and see if any of them help. I see they all assume that the Activity being used is ListActivity, not sure this makes a difference, but mine is just an Activity comprised of various views, 2 of which are ListViews. Thanks though, I'll revert if these help. – stephen mc Jul 30 '12 at 08:54