Android的适配器视图? [英] Android AdapterView?
问题描述
<一个href="http://developer.android.com/guide/topics/ui/declaring-layout.html#CommonLayouts">Documents说:
当你的布局内容是动态还是不pre-确定,您 可以使用布局子类适配器视图来填充版面 有观点在运行时。该适配器视图类的子类使用一个 适配器将数据绑定到其布局。
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.
但大多数教程约的ListView
,的GridView
,微调
和图库
。
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?
推荐答案
首先,你应该绝对确保适配器视图
是你想要的,因为不是所有的动态或没有pre-决定的意见可通过适配器视图
实施。有时候,你最好创建扩展视图的ViewGroup
。
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
.
如果你想使用适配器视图
,看看<一href="http://developer.sonymobile.com/2010/05/20/android-tutorial-making-your-own-3d-list-part-1/">this非常好的例子的。有很多的自定义视图使用适配器在GitHub上。 看看这一个(扩展的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
).
这篇关于Android的适配器视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!