DeviceInfoItemAdapter.java
2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.sw.laryngoscope.adapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.sw.laryngoscope.R;
import com.sw.laryngoscope.db.DeviceInfoBean;
import java.util.List;
public class DeviceInfoItemAdapter extends BaseAdapter {
private String TAG = getClass().getSimpleName();
private LayoutInflater mInflater;
private OnClickListener mlisten;
private List<DeviceInfoBean> beans;
// 定义Context
private Context mContext;
public DeviceInfoItemAdapter(Context c, List<DeviceInfoBean> paramArrayList) {
mContext = c.getApplicationContext();
mInflater = LayoutInflater.from(c);
this.beans = paramArrayList;
}
public void setBeans(List<DeviceInfoBean> beans) {
this.beans = beans;
}
public int getCount() {
return beans.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public void setUpdateListener(OnClickListener listen) {
mlisten = listen;
}
@SuppressLint("ResourceAsColor")
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if ( convertView == null ) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_device_info, null);
ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT,39);//设置宽度和高度
convertView.setLayoutParams(params);
holder.txt_info = (TextView)convertView.findViewById(R.id.txt_info);
holder.txt_value = (TextView)convertView.findViewById(R.id.txt_value);
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
DeviceInfoBean bean = (DeviceInfoBean)this.beans.get(position);
holder.txt_info.setText(bean.getTxt_cap() + "");
holder.txt_value.setText(bean.getTxt_value() + "");
return convertView;
}
public final class ViewHolder {
public TextView txt_info;
public TextView txt_value;
}
public interface OnClickListener {
void onClickEvent(int id);
}
}