Adapter 和 AdapterView 之间的契约
是否有某个地方描述了 Adapter 和 AdapterView 之间或 ListView 和 ListViewAdapter 之间的约定。
我正在尝试创建自己的 ListView 适配器。我不清楚方法调用的顺序,也不清楚谁可能调用这些方法。
似乎有几种重叠的方法。
- getItem 返回一个数据对象,但是 你不知道类型。
- getItemViewType 返回一个整数。整数由谁决定?他们是吗 在某处定义?用户定义?
- getView
getView 似乎是唯一真正重要的。可能涉及哪些其他代码会尝试对返回的数据和返回的视图执行某些操作?如果两者的类型都不知道,其他代码如何知道如何将数据分配给视图?
对设计的一般解释会很有帮助。
Is there some place which describes the contract between Adapter and AdapterView, or between ListView and ListViewAdapter.
I'm trying to create my own ListView Adapter. It is not clear to me the sequence of method invocations nor who maybe calling these methods.
There appear to be several overlapping methods.
- getItem returns a data object, but
you don't know the type. - getItemViewType returns an integer. Who determines the integer? Are they
defined somewhere? Userdefined? - getView
getView seems to be the only one that really matters. What other code maybe involved that would try to do something with the returned data and returned view? How can this other code know how to assign the data to the view if the type of neither is known?
A general explanation of the design would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你必须查看 android 源代码:
http://www.google.co.in/codesearch/p?hl=fr#uX1GffpyOZk/core/java/android/widget/AdapterView.java&q=adapterView& sa=N&cd=1&ct=rc
I think you will have to look into android source code :
http://www.google.co.in/codesearch/p?hl=fr#uX1GffpyOZk/core/java/android/widget/AdapterView.java&q=adapterView&sa=N&cd=1&ct=rc