MyApp

【MyApp】莫问天涯路几重,轻衫侧帽且从容。这篇文章主要讲述MyApp相关的知识,希望能为你提供帮助。

package com.example.week;

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

import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
* Created by 生哥 on 2017/12/2.
*/

public class My extends BaseAdapter{
private List< News.NewslistBean> list;
private Context context;

public My(List< News.NewslistBean> list, Context context) {
this.list = list;
this.context = context;
}

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

@Override
public Object getItem(int position) {
return list.get(position);
}

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

@Override
public View getView(int position, View v, ViewGroup parent) {
VH vh;
if (v == null){
vh = new VH();
v = View.inflate(context, R.layout.list,null);
vh.tv1 = v.findViewById(R.id.List_Title);
vh.tv2 = v.findViewById(R.id.List_riqi);
vh.iv = v.findViewById(R.id.List_tu);
v.setTag(vh);
}else {
vh = (VH) v.getTag();
}
vh.tv1.setText(list.get(position).getTitle());
vh.tv2.setText(list.get(position).getCtime());
String pic_url = list.get(position).getPicUrl();
ImageLoader.getInstance().displayImage(pic_url,vh.iv);
return v;
}
class VH{
TextView tv1,tv2;
ImageView iv;
}
}


































































    推荐阅读