zoukankan      html  css  js  c++  java
  • ssss

    package com.bwie.adapter;

    import java.util.List;

    import com.bwie.test.R;
    import com.bwie.vo.Data;
    import com.lidroid.xutils.BitmapUtils;

    import android.content.Context;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.TextView;

    public class MyAdapter extends BaseAdapter {
        private Context context;
        private List<Data> list;
        public MyAdapter(Context context, List<Data> list) {
            super();
            this.context = context;
            this.list = list;
        }

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return list.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) {
            // TODO Auto-generated method stub
            ViewHodler vh;
            String imageurl = list.get(position).getIMAGEURL();
            if(imageurl==null){
                    vh = new ViewHodler();
                    convertView = LayoutInflater.from(context).inflate(R.layout.listview_item, null);
                    vh.title1 = (TextView) convertView.findViewById(R.id.title1);
                    vh.fromname1 = (TextView) convertView.findViewById(R.id.fromname1);
                    vh.time1 = (TextView) convertView.findViewById(R.id.time1);
                    vh.title1.setText(list.get(position).getTITLE());
                    vh.fromname1.setText(list.get(position).getFROMNAME());
                    vh.time1.setText(list.get(position).getSHOWTIME());
            }else{
                    vh = new ViewHodler();
                    convertView = LayoutInflater.from(context).inflate(R.layout.listview_item1, null);
                    vh.title2 = (TextView) convertView.findViewById(R.id.title2);
                    vh.fromname2 = (TextView) convertView.findViewById(R.id.fromname2);
                    vh.time2 = (TextView) convertView.findViewById(R.id.time2);
                    vh.image = (ImageView) convertView.findViewById(R.id.imageView);
                
                    vh.title2.setText(list.get(position).getTITLE());
                    vh.fromname2.setText(list.get(position).getFROMNAME());
                    vh.time2.setText(list.get(position).getSHOWTIME());
                    BitmapUtils utils = new BitmapUtils(context);
                    utils.display(vh.image, list.get(position).getIMAGEURL());
                
                
            }
            return convertView;
        }
        class ViewHodler{
            TextView title1,title2,fromname1,fromname2,time1,time2;
            ImageView image;
        }
    }

  • 相关阅读:
    HDU 1016 Prime Ring Problem
    CreateRemoteThread函数多參数传入用法
    Dynamics CRM2015 on-premises直接升级Dynamics CRM2016 on-premises
    cocos2d-x+lua代码热载入(Hot Swap)的研究
    DirectX 9.0c游戏开发手记之“龙书”第二版学习笔记之8: Chap10: Lighting
    js合并table单元格(拼table的时候并不知道详细几行几列)
    简单图模板 Graph
    POJ-3278-Catch That Cow-广搜(BFS)
    android用存到缓存的方法来保存ListView里的数据
    Ubuntu 14.10中连接Win10的smb共享文件
  • 原文地址:https://www.cnblogs.com/strive-zcg/p/5403322.html
Copyright © 2011-2022 走看看