package com.txsc.adapter; import java.util.List; import com.txsc.R; import com.txsc.bean.GoodsInfoBean; import com.txsc.view.CollectPopWindow; import android.content.Context; import android.graphics.Color; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; /** * 商品属性选择ListAdapter * @author linshao * * @data 2015-5-14 下午12:38:50 * */ public class Attr_ListAdapter extends BaseAdapter { private List<GoodsInfoBean.attrBean> mList; private LayoutInflater mLay; private Context mContext; public Attr_ListAdapter(Context context, List<GoodsInfoBean.attrBean> list) { this.mList = list; this.mContext = context; this.mLay = LayoutInflater.from(mContext); } @Override public int getCount() { return mList.size(); } @Override public Object getItem(int position) { return mList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder = null; if (convertView == null) { holder = new ViewHolder(); convertView = mLay.inflate(R.layout.p2_list_item_attr_list, null); holder.tv_Name = (TextView) convertView .findViewById(R.id.tv_good_name); holder.tv_State = (TextView) convertView .findViewById(R.id.tv_good_state); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.tv_Name.setText(mList.get(position).getStandard()); if (mList.get(position).getIsDefect() == 0) { holder.tv_State.setText("有货"); } if (position == CollectPopWindow.posi) { convertView.setBackgroundColor(Color.parseColor("#00ff00")); } else { convertView.setBackgroundColor(Color.parseColor("#ffffff")); } return convertView; } public void addData(List<GoodsInfoBean.attrBean> beanList) { this.mList.addAll(beanList); } public void clearData() { this.mList.clear(); } class ViewHolder { TextView tv_Name, tv_State; } }