package safeluck.drive.evaluation.adapter;
|
|
import android.content.Context;
|
import android.graphics.drawable.Drawable;
|
import android.util.Log;
|
import android.view.LayoutInflater;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.widget.BaseAdapter;
|
import android.widget.TextView;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import safeluck.drive.evaluation.R;
|
|
/**
|
* MyApplication2
|
* Created by lzw on 2020/1/10. 16:33:13
|
* 邮箱:632393724@qq.com
|
* All Rights Saved! Chongqing AnYun Tech co. LTD
|
*/
|
|
public class GpsInfoAdapter extends BaseAdapter {
|
private List<String> persons = new ArrayList<>();//gps信息
|
private final static String TAG = "anyun_info";
|
private Context mContext;
|
@Override
|
public int getCount() {
|
return persons.size();
|
}
|
|
@Override
|
public String getItem(int i) {
|
return persons.get(i);
|
}
|
|
@Override
|
public long getItemId(int i) {
|
return i;
|
}
|
|
@Override
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
InfoHodler infoHodler = null;
|
if (view == null){
|
view = LayoutInflater.from(mContext).inflate(R.layout.gps_info_item,null);
|
infoHodler = new InfoHodler();
|
infoHodler.name = view.findViewById(R.id.text_check_info);
|
view.setTag(infoHodler);
|
}else{
|
infoHodler = (InfoHodler) view.getTag();
|
}
|
|
infoHodler.name.setText(getItem(i));
|
return view;
|
}
|
|
public GpsInfoAdapter(Context mContext) {
|
this.mContext = mContext;
|
}
|
/**
|
* //先清掉原来的所有数据再添加新加进来所有的数据
|
* @param ps
|
*/
|
public void addAll(List<String> ps){
|
persons.clear();//先清掉原来的所有数据
|
persons.addAll(ps);//再添加新加进来所有的数据
|
notifyDataSetChanged();//刷新界面
|
}
|
|
static class InfoHodler {
|
|
|
public TextView name;//姓名
|
|
|
|
|
|
}
|
|
}
|