• 一个继承BaseAdapter的适配器的例子


    public class AroundAdapter extends BaseAdapter {
        private ArrayList<MaintanceShopItem> aroundList;
        private LayoutInflater inflater;
        private ImageFetcher imageFetcher;
    
        public AroundAdapter(Context context) {
            inflater = LayoutInflater.from(context);
        }
    
        public AroundAdapter(Context context, ArrayList<MaintanceShopItem> urgents) {
            this.aroundList = urgents;
            inflater = LayoutInflater.from(context);
            notifyDataSetInvalidated();
        }
    
        public AroundAdapter(Context context, ArrayList<MaintanceShopItem> urgents,
                ImageFetcher imageFetcher) {
            this.aroundList = urgents;
            inflater = LayoutInflater.from(context);
            this.imageFetcher = imageFetcher;
            notifyDataSetInvalidated();
        }
        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return aroundList == null ? 0 : aroundList.size();
        }
    
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return aroundList.get(position);
        }
    
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return position;
        }
    
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder viewHolder = null;
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.around_list_item, null);
                viewHolder = new ViewHolder();
                viewHolder.around_imageview = (ImageView) convertView.findViewById(R.id.around_imageView1);
                viewHolder.around_complany_name = (TextView) convertView.findViewById(R.id.around_complany_name);
                viewHolder.around_complany_address = (TextView) convertView.findViewById(R.id.around_complany_address);
                viewHolder.around_complany_distance = (TextView) convertView
                        .findViewById(R.id.around_complany_distance);
                viewHolder.around_complany_star = (RatingBar) convertView.findViewById(R.id.around_complany_start);
                viewHolder.around_complany_scope = (TextView) convertView.findViewById(R.id.around_complany_scope);
                convertView.setTag(viewHolder);
            } else {
                viewHolder = (ViewHolder) convertView.getTag();
            }
            MaintanceShopItem item = aroundList.get(position);
            viewHolder.around_complany_name.setText(item.getStoreBasic().getStoreName());
            viewHolder.around_complany_address.setText(item.getStoreBasic().getStoreAddress());
            String kilomiter = String.valueOf(Integer.parseInt(item.getStoreBasic().getStoreDistance()) / 10 / 100.0)
                    + "Km";
            viewHolder.around_complany_distance.setText(kilomiter);
            viewHolder.around_complany_star.setStepSize(0.5f);
            viewHolder.around_complany_star.setRating(Float.valueOf(item.getStoreBasic().getStoreStar()));
            viewHolder.around_complany_scope.setText(item.getStoreBasic().getStoreScope());
            //dealing with the image url
            viewHolder.around_imageview.setTag(item.getStoreBasic().getStoreImage());// ���ñ�ǩ
            Log.v("imageUrl", item.getStoreBasic().getStoreImage());
            if (imageFetcher != null)
                imageFetcher.loadImage(item.getStoreBasic().getStoreImage(), viewHolder.around_imageview); 
            
            
            return convertView;
        }
        static class ViewHolder {
            private ImageView around_imageview;
            private TextView around_complany_name;
            private TextView around_complany_address;
            private TextView around_complany_distance;
            private RatingBar around_complany_star;
            private TextView around_complany_scope;
        }
    }
  • 相关阅读:
    centos6 LVS-DR模式---分析
    centos6.6 安装 LXC
    Amoeba-mysql读写分离实战
    keepalived +mysql 实战
    nginx添加sticky模块-cookie保持会话
    haproxy转发真实IP给web
    Mysql-如何正确的使用索引以及索引的原理
    Mysql-自带的一些功能,基本用法(视图,触发器,事务,存储过程,函数,流程控制)
    Mysql-常用数据的基本操作和基本形式
    Mysql-多表连接的操作和用法
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3012508.html
Copyright © 2020-2023  润新知