CursorAdapter中getView newView bindView的作用

摘要 Adapter的作用是界面与数据之间的桥梁,通过设置适配器至ListView控件后(如调用ListView的setAdapter(ListAdapteradapter) ),列表的每一项会显示至页面中。其实,当列表里的每一项显示到页面时,都会调用 Adapter的getView方法 返回一个View,如: @Overrid

Adapter的作用是界面与数据之间的桥梁,通过设置适配器至ListView控件后(如调用ListView的 setAdapter(ListAdapter adapter) 

                            
),列表的每一项会显示至页面中。其实,当列表里的每一项显示到页面时,都会调用Adapter的getView方法返回一个View,如:                                

@Override                                                                                                                        
public View getView(int position, View convertView, ViewGroup parent) {                                                          
        return super.getView(position, convertView, parent);                                                                     
}

                                                                                                
CursorAdapter中提供了这两个抽象方法:
//Makes a new view to hold the data pointed to by cursor.
public abstract View newView(Context context, Cursor cursor, ViewGroup parent);
//Bind an existing view to the data pointed to by cursor
public abstract void bindView(View view, Context context, Cursor cursor);

**newView和bindView细化了getView中的功能实现,均可写在getView中代替。
**
三者的调用顺序为:
getView——>newView——>bindView