1, ListView 的Adapter 继承 BaseAdapter
2,通过getView()中的 holder 与convertView 进行布局的重用
class TwosListAdapter extends BaseAdapter{
private List<String> list ;
public TwosListAdapter(List<String> list) {
this.list = list;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup viewGroup) {
ViewHolder holder ;
if (convertView==null){
holder = new ViewHolder();
convertView = LayoutInflater.from(getActivity()).inflate(R.layout.twofragments_list_item_layout,null);
holder.item_layout = (LinearLayout) convertView.findViewById(R.id.item_layout);
holder.gcs_name =(TextView) convertView.findViewById(R.id.gcs_name);
holder.gcs_renzheng =(TextView) convertView.findViewById(R.id.gcs_renzheng);
holder.gcs_gonghao =(TextView) convertView.findViewById(R.id.gcs_gonghao);
holder.gcs_gaojigongchengshi =(TextView) convertView.findViewById(R.id.gcs_gaojigongchengshi);
holder.gcs_dazhuanxueli =(TextView) convertView.findViewById(R.id.gcs_dazhuanxueli);
holder.gcs_jianjie =(TextView) convertView.findViewById(R.id.gcs_jianjie);
holder.gcs_Progress = (ProgressBar) convertView.findViewById(R.id.gcs_Progress);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
holder.item_layout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setClass(getActivity(),GcsXiangqing.class);
startActivity(intent);
}
});
return convertView;
}
class ViewHolder{
LinearLayout item_layout ;
TextView gcs_name ,
gcs_renzheng ,
gcs_gonghao,
gcs_gaojigongchengshi,
gcs_dazhuanxueli ,
gcs_jianjie;
ProgressBar gcs_Progress ;
}
}