Forum Xamarin.Android

What to return from GetItem in an Adapter

StuartLodgeStuartLodge USBeta ✭✭✭

Back last year, I stubbed out the public override Object GetItem(int position) calls in my Adapters to return null.

This was to avoid GREF issues - see

However... the problem with this is it breaks the AutoCompleteTextView from working - see

I think I'm about to enable the GetItem call again - just for those views... but, before I do, I thought I'd ask: does anyone have any different ideas? Extra bonus points for better ones!


  • GlennWilsonGlennWilson USUniversity ✭✭

    My rather naive thought (and I was not aware that there was an issue until I read this) is don't "new" an item in GetItem. Returning null does that. But, also...

    Depending on the use pattern, though, could you cache the items? Are you "new"ing the "same" items over and over for a fairly small list?

    Or, similar, maintain a Pool of your MvxJavaContainer wrapper class and instead of making new ones grab one from the pool and populate it with the proper SourceItem (or just give it enough information so that it could get the correct source item if it was actually needed)?

    In the Pool case I can see a challenge in knowing when you could release the instance back to the Pool...

Sign In or Register to comment.