FileItemAdapter.java
3.87 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.sw.laryngoscope.R;
import com.sw.laryngoscope.db.FileDayBean;
import com.sw.laryngoscope.widget.IMGRigTopPointView;
import java.util.List;
public class FileItemAdapter extends BaseAdapter {
private String TAG = getClass().getSimpleName();
private LayoutInflater mInflater;
private OnClickListener mlisten;
private List<FileDayBean> beans;
private int pos;
// 定义Context
private Context mContext;
FileRvAdapter rvAdapter;
private int selPos = -1;
public FileItemAdapter(Context c, List<FileDayBean> paramArrayList, int pos, FileRvAdapter rvAdapter) {
mContext = c.getApplicationContext();
mInflater = LayoutInflater.from(c);
this.beans = paramArrayList;
this.pos = pos;
this.rvAdapter = rvAdapter;
selPos = -1;
}
public void setBeans(List<FileDayBean> beans) {
this.beans = beans;
}
public int getCount() {
/*Log.d(TAG, "==================" + mImageIds.length);*/
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;
// Logger.d(" getView position " + position + " beans " + beans.size());
if ( convertView == null ) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_file_info, null);
//设置宽度和高度
ListView.LayoutParams params = new ListView.LayoutParams(ListView.LayoutParams.MATCH_PARENT, 121);
convertView.setLayoutParams(params);
holder.lay_filelist = (LinearLayout)convertView.findViewById(R.id.lay_filelist);
holder.lay_value = (RelativeLayout)convertView.findViewById(R.id.lay_value);
holder.item_file_num = (ImageView)convertView.findViewById(R.id.item_file_num);
holder.txt_name = (TextView)convertView.findViewById(R.id.txt_name);
holder.txt_time = (TextView)convertView.findViewById(R.id.txt_time);
holder.txt_note = (TextView)convertView.findViewById(R.id.txt_note);
convertView.setTag(holder);
} else {
holder = (ViewHolder)convertView.getTag();
}
final FileDayBean bean = this.beans.get(position);
if ( selPos == position ) {
//holder.lay_value.setBackgroundResource(R.drawable.bg_user_sideview_gray);
/*holder.lay_userlist.setBackgroundColor(
mContext.getResources().getColor(R.color.color_white));*/
} else {
//holder.lay_value.setBackgroundResource(R.drawable.bg_user_sideview);
}
holder.txt_name.setText(bean.getItemName());
holder.txt_time.setText(bean.getItemTime());
//holder.txt_note.setText("");
holder.txt_note.setText(bean.getNote());
holder.lay_value.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if ( rvAdapter.getListener() != null ) {
rvAdapter.getListener().onSubItemsFileClick(pos, position, bean.getItemName());
}
}
});
return convertView;
}
public final class ViewHolder {
public LinearLayout lay_filelist;
public RelativeLayout lay_value;
public ImageView item_file_num;
public TextView txt_name;
public TextView txt_time;
public TextView txt_note;
}
public interface OnClickListener {
void onClickEvent(int id);
}
}