Adapter中的getView方法

public abstract View getView (int position, View convertView, ViewGroup parent)

引入自: API 级别1

Get a View that displays the data at the specified position in the data set. You can either create a View manually or inflate it from an XML layout file. When the View is inflated, the parent View (GridView, ListView...) will apply default layout parameters unless you use inflate(int, android.view.ViewGroup, boolean) to specify a root view and to prevent attachment to the root.


获得一个View,这个View显示了在数据集中指定位置的数据,你既可以用手工创建一个View也可以把它从一个XML布局文件中inflate出来。当这个View被Inflate后,其父View(GridView,ListView...)会设置一个默认的参数除非你用inflate(int, android.view.ViewGroup, boolean)方法去指定一个根View并且去阻止附加到其根上。

参数
position 要从适配器中取得的视图的位置.
convertView The old view to reuse, if possible. Note: You should check that this view is non-null and of an appropriate type before using. If it is not possible to convert this view to display the correct data, this method can create a new view.
如果可能的话,这是被重用的老的View。
parent
The parent that this view will eventually be attached to
最终被附加到的父View
返回值
  • A View corresponding to the data at the specified position.
  • 返回一个对应于指定位置的View。

你可能感兴趣的:(Adapter中的getView方法)