Android——打造万能适配器(CommonAdapter)

List<T> : ListView -> Adapter extends BaseAdapter -> ViewHolder

 

ViewHolder

CommonAdaper

 

通用的ViewHolder类

convertView.setTag(holder);

ViewHolder:Item各种控件的引用

 

Map<int, View> -> SpareArray

getView(int id);

 

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

  ViewHolder holder = ...

  TextView tv  = holder.getView(viewId);

  tv.setText(...);

}

posted @ 2016-05-15 18:02  AnglusWang  阅读(789)  评论(0编辑  收藏  举报