轮播图界面 CTwoFragment CTwoAdapter

package com.bwie.lenovo.yk1.adapter;

import android.content.Context;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bwie.lenovo.yk1.R;
import com.bwie.lenovo.yk1.bean.COneBean;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

public class CTwoAdapter extends BaseAdapter {
    private Context context;
    private List<COneBean.ResultsBean> resultsBeans;

    public CTwoAdapter(Context context, List<COneBean.ResultsBean> resultsBeans) {
        this.context = context;
        this.resultsBeans = resultsBeans;
    }

    @Override
    public int getCount() {
        return resultsBeans.size();
    }

    @Override
    public COneBean.ResultsBean getItem(int position) {
        return resultsBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=null;
        if(convertView==null){
            holder=new ViewHolder();
            convertView=View.inflate(context, R.layout.channel_two_listitem2,null );
            holder.ivImage=convertView.findViewById(R.id.tv_image);
            holder.tvText=convertView.findViewById(R.id.tv_text);
            convertView.setTag(holder);
        }else {
            holder= (ViewHolder) convertView.getTag();
        }
        holder.tvText.setText(resultsBeans.get(position).getDesc());
        if (resultsBeans.get(position).getImages()!=null){
            ImageLoader.getInstance().displayImage(resultsBeans.get(position).getImages().get(0), holder.ivImage);
        }

        return convertView;
    }
    class ViewHolder{
        ImageView ivImage;
        TextView tvText;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值