• 一个继承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;
        }
    }
  • 相关阅读:
    04. SpringCloud实战项目-安装Docker
    03. SpringCloud实战项目-配置虚拟机网络
    02. SpringCloud实战项目-快速搭建Linux环境-运维必备
    01. SpringCloud实战项目-五分钟搞懂分布式基础概念
    docker安装redis
    docker 安装mysql
    安装docker
    配置虚拟机网络
    Vagrant快速搭建Ubuntu虚拟机环境
    5分钟搞懂分布式基础概念
  • 原文地址:https://www.cnblogs.com/linxiaojiang/p/3012508.html
Copyright © 2020-2023  润新知