【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;
}
}
推荐阅读
- AndroidActivity生命周期研究
- 浅析$watch ,$apply 和 $digest (Angular篇)
- 我的Android手册
- 安卓初次完美调试,并成功编程!
- Android系统启动流程解析init进程启动过程
- Android中实现OkHttp上传文件到服务器并带进度
- 安卓延时执行代码
- Unity20172.0 Android平台打包
- Android后端服务器的搭建方法