EventAdapter.java
1.85 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
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.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by martin on 21/02/2017.
*/
public class EventAdapter extends BaseAdapter {
public List<Event> mList;
public Context mContext;
public LayoutInflater mInflater;
public EventAdapter(Context context, List<Event> aList) {
mContext = context;
mList = aList;
mInflater = LayoutInflater.from(mContext);
}
public int getCount() {
return mList.size();
}
public Object getItem(int position) {
return mList.get(position);
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
LinearLayout layoutItem;
if (convertView == null) {
layoutItem = (LinearLayout) mInflater.inflate(R.layout.event, parent, false);
} else {
layoutItem = (LinearLayout) convertView;
}
TextView date = (TextView) layoutItem.findViewById(R.id.date);
TextView event = (TextView) layoutItem.findViewById(R.id.event);
date.setText(mList.get(position).getDate());
event.setText(mList.get(position).getEvenement());
return layoutItem;
}
public interface EventAdapterListener {
void onClickButton(Event item, int position);
}
private ArrayList<EventAdapterListener> mListListener = new ArrayList<EventAdapterListener>();
public void addListener(EventAdapterListener aListener) {
mListListener.add(aListener);
}
}