Android AdapterView?

Student Student picture Student Student · Feb 4, 2013 · Viewed 22.6k times · Source

Documents say:

When the content for your layout is dynamic or not pre-determined, you can use a layout that subclasses AdapterView to populate the layout with views at runtime. A subclass of the AdapterView class uses an Adapter to bind data to its layout.

But most of tutorials are in about ListView,GridView,Spinner and Gallery.

I'm looking to extend a subclass directly from AdapterView. I have to create a custom view that it's content is dependent to an adapter.

How can I do this, and what methods must be overridden?

Answer

Leonidos picture Leonidos · Feb 8, 2013

First, you should be absolutely sure that AdapterView is what you want, because not all "dynamic or not pre-determined" views can be implement via AdapterView. Sometimes you'd better create your view extending ViewGroup.

if you want to use AdapterView, take a look at this really nice example. There are a lot of custom views with adapter on GitHub. Check out this one (extends ViewGroup).