public class MyListAdapter extends BaseAdapter {
Integer [] imgList = {R.drawable.kob,R.drawable.joje,
R.drawable.baarg,R.drawable.zereshk};
String [] nameList = {"کوبیده","جوجه","برگ","زرشک پلو"};
String [] subNameList = {"کوبیده","جوجه","برگ","زرشک پلو"};
String [] priceList = {"12000 تومان","14000 تومان","19000 تومان","13000 تومان"};
String [] tvCountList = {" 0 "," 0 "," 0 "," 0 "};
Context context;
LayoutInflater layoutInflater;
int count;
public MyListAdapter (Context context){
this.context = context;
layoutInflater=(LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return imgList.length;
}
@Override
public Object getItem(int position) {
return imgList[position];
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View view, ViewGroup parent) {
view = layoutInflater.inflate(R.layout.activity_my_list_adapter,null);
ImageView imageViewList=(ImageView)view.findViewById(R.id.imageViewList);
ImageView imgPlus=(ImageView)view.findViewById(R.id.imageViewPlus);
ImageView imgNegative=(ImageView)view.findViewById(R.id.imageViewNegative);
TextView tvName = (TextView)view.findViewById(R.id.textViewName);
TextView tvSubName = (TextView)view.findViewById(R.id.textViewSubName);
TextView tvPrice = (TextView)view.findViewById(R.id.textViewPrice);
TextView tvCount = (TextView)view.findViewById(R.id.textViewCount);
imgPlus.setImageResource(R.drawable.greenplus);
imgNegative.setImageResource(R.drawable.rednegative);
imageViewList.setImageResource(imgList[position]);
tvName.setText(nameList[position]);
tvSubName.setText(subNameList[position]);
tvPrice.setText(priceList[position]);
tvCount.setText(tvCountList[position]);
return view;
}
}