回调在Android的适配器接口 [英] Callbacks for Adapter interface in Android

查看:317
本文介绍了回调在Android的适配器接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找在适配器接口文档在 http://developer.android .COM /参考/安卓/空间/ Adapter.html 。我发现有几个回调方法,这些接口有像

I was looking at the Adapter interface documentation at http://developer.android.com/reference/android/widget/Adapter.html. I found that there are several callback methods that these interface has like

抽象对象的getItem(INT位置)
获得与在数据集中的指定位置相关联的数据项。

abstract Object getItem(int position) Get the data item associated with the specified position in the data set.

抽象长getItemId(INT位置)
获取与列表中的指定位置相关联的行ID。

abstract long getItemId(int position) Get the row id associated with the specified position in the list.

抽象INT getItemViewType(INT位置)
获取将被getView(INT,查看,ViewGroup中)指定项目创建视图的类型。

abstract int getItemViewType(int position) Get the type of View that will be created by getView(int, View, ViewGroup) for the specified item.

抽象INT getViewTypeCount()
返回将由getView(INT,查看,ViewGroup中)。

abstract int getViewTypeCount() Returns the number of types of Views that will be created by getView(int, View, ViewGroup).

这通常是没有实现。我还没有发现其实施的任何
我所遇到的适配器接口实现。该文档无法解释时,他们将被调用,如何将它们很好地使用。没有任何例子。将AP preciate如果有人能够阐明他们的一些情况。

which are usually not implemented. I haven't found their implementation an any of the Adapter interface implementations that I have come across. The documentation fails to explain when they will be called and how they can be put to good use. No examples whatsoever. Would appreciate if someone can shed some light on them.

推荐答案

这些方法会被链接到您的适配器适配器视图(对于exeample,一个ListView)被调用。

Those methods will be called by the AdapterView (for exeample, a ListView) that is linked to your Adapter.

在适配器视图图纸阶段,这些方法会为了呼吁,以便得到正确的数据在屏幕上的特定位置显示。

During the AdapterView drawing phase, those methods will be called in order for the view to get the right data to display at a specific place on the screen.

您应该谷歌适配器教程(如: http://www.vogella.com /articles/AndroidListView/article.html

You should google for Adapter tutorial (ex : http://www.vogella.com/articles/AndroidListView/article.html)

这篇关于回调在Android的适配器接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆