package com.ttj.adapter; import java.util.List; import android.content.Context; import android.graphics.drawable.Drawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.ttj.R; import com.ttj.bean.AgentAreaBean; import com.ttj.bean.AreaListBean; /** * 城市选择adapter * * @author linshao * * @data 2015-5-14 下午12:38:34 * * *@author zwy *#添加 img_arrow_right 以及对其的处理 同时修改的有 list_item_data_check.xml :添加了drawableright属性 *#修改addData()方法 添加参数 int i 同时 Area_AddAty.java 调用 addData是添加了传递的参数 */ public class Add_CityAdapter extends BaseAdapter { private Context mContext; private List<AgentAreaBean> mList; private LayoutInflater inflater; private boolean isLastSelectPager = false; public Add_CityAdapter(Context context, List<AgentAreaBean> list) { this.mContext = context; this.mList = list; inflater = 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(int arg0, View v, ViewGroup arg2) { if (v == null) { v = inflater.inflate(R.layout.list_item_data_check, null); } TextView textView = (TextView) v .findViewById(R.id.text_list_item_data_check); if (isLastSelectPager) { textView.setCompoundDrawables(null, null, null, null); } else { Drawable drawable = mContext.getResources().getDrawable( R.drawable.img_arrow_right); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); textView.setCompoundDrawables(null, null, drawable, null); } textView.setText(mList.get(arg0).getAreaCaption()); return v; } /** * * @author zwy * @param i 表示地址选择的页数,1:省份 2:城市 3:区域 4:-- (仅判断是否是3 即最后选择页不带箭头) */ public void addData(List<AgentAreaBean> beanList, int i) { this.mList.addAll(beanList); if (i == 3) { isLastSelectPager = true; } else isLastSelectPager = false; } public void clearData() { this.mList.clear(); } }