b8e00f52
martin.rohmer
mise à dispositio...
|
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
|
package com.example.martin.projetv5;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by martin on 20/02/2017.
*/
public class PriseAdapterMedoc extends BaseAdapter {
public List<Prise2> mListP;
public Context mContext;
public LayoutInflater mInflater;
public PriseAdapterMedoc(Context context, List<Prise2> aListP){
mContext = context;
mListP = aListP;
mInflater = LayoutInflater.from(mContext);
}
public int getCount(){
return mListP.size();
}
public Object getItem(int position){
return mListP.get(position);
}
public long getItemId(int position){
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout layoutItem;
if (convertView == null) {
layoutItem = (RelativeLayout) mInflater.inflate(R.layout.prise_medoc, parent, false);
} else {
layoutItem = (RelativeLayout) convertView;
}
TextView horloge = (TextView) layoutItem.findViewById(R.id.horloge);
ImageButton change = (ImageButton) layoutItem.findViewById(R.id.boutonConfirm);
horloge.setText(mListP.get(position).getHeure());
change.setImageResource(R.drawable.delete);
change.setTag(position);
change.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Integer position = (Integer)v.getTag();
sendListener(mListP.get(position),position);
}
});
return layoutItem;
}
public interface PriseAdapterListener{
void onClickDelete(Prise2 item, int position);
}
private ArrayList<PriseAdapterListener> mListListener = new ArrayList<PriseAdapterListener>();
public void addListener(PriseAdapterListener aListener){
mListListener.add(aListener);
}
private void sendListener(Prise2 item, int position){
for(int i = mListListener.size()-1; i>=0; i--){
mListListener.get(i).onClickDelete(item, position);
}
}
}
|