forked from jwzhangjie/-ScrollerDelete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeleteAdapter.java
104 lines (90 loc) · 2.46 KB
/
DeleteAdapter.java
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
package com.jwzhangjie.scrollview;
import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class DeleteAdapter extends BaseAdapter {
public static ListItemDelete itemDelete = null;
private List<String> listDatas;
private LayoutInflater mInflater;
private Context context;
public DeleteAdapter(Context context, List<String> listDatas) {
mInflater = LayoutInflater.from(context);
this.listDatas = listDatas;
this.context = context;
}
@Override
public int getCount() {
return listDatas == null ? 0 : listDatas.size();
}
@Override
public Object getItem(int position) {
return listDatas.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.item_delete, null);
holder.itemData = (TextView) convertView
.findViewById(R.id.itemData);
holder.btnDelete = (Button) convertView
.findViewById(R.id.btnDelete);
holder.btnNao = (Button) convertView.findViewById(R.id.btnNao);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
holder.btnDelete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showInfo("点击删除了");
}
});
holder.itemData.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showInfo("点击了数据: " + listDatas.get(position));
}
});
holder.btnNao.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
showInfo("点击了闹铃");
}
});
holder.itemData.setText(listDatas.get(position));
return convertView;
}
class ViewHolder {
TextView itemData;
Button btnDelete;
Button btnNao;
}
private Toast mToast;
public void showInfo(String text) {
if (mToast == null) {
mToast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
} else {
mToast.setText(text);
mToast.setDuration(Toast.LENGTH_SHORT);
}
mToast.show();
}
public static void ItemDeleteReset() {
if (itemDelete != null) {
itemDelete.reSet();
}
}
}