-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathadapter.txt
58 lines (40 loc) · 1.38 KB
/
adapter.txt
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
public class TagAdapter extends RecyclerView.Adapter<TagAdapter.Viewholder> {
private ArrayList<TagsModel> data;
private TagsModel model;
private Context context;
public TagAdapter(ArrayList<TagsModel> data, Context context) {
this.data = data;
this.context = context;
}
public static class Viewholder extends RecyclerView.ViewHolder {
// 1. Declare your Views here
public TextView tagText;
public Viewholder(View itemView) {
super(itemView);
// 2. Define your Views here
tagText = (TextView)itemView.findViewById(R.id.tag_text);
}
}
@Override
public Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.tags_row, parent, false);
return new Viewholder(itemView);
}
@Override
public void onBindViewHolder(Viewholder holder, int position) {
model = data.get(position);
// 3. set the data to your Views here
/**
*
The format to set data should be like this example:
--------------------------------------
holder.txvName.setText(model.getName());
*
*/
}
@Override
public int getItemCount() {
return data.size();
}
}