-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShopCategoryAdapter.java
51 lines (39 loc) · 1.37 KB
/
ShopCategoryAdapter.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
package com.ikai.unitshop;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import java.util.List;
/**
* Created by shiv on 16/11/17.
*/
class ShopCategoryAdapter extends RecyclerView.Adapter<ShopCategoryAdapter.MyViewHolder> {
// Variable to hold all category name.
private List<ShopCategory> shopCategoryList;
ShopCategoryAdapter(List<ShopCategory> shopCategoryList) {
this.shopCategoryList = shopCategoryList;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.single_shop_category, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
ShopCategory shopCategory = shopCategoryList.get(position);
holder.catText.setText(shopCategory.getCategoryName());
}
@Override
public int getItemCount() {
return shopCategoryList.size();
}
class MyViewHolder extends RecyclerView.ViewHolder {
Button catText;
MyViewHolder(View itemView) {
super(itemView);
catText = itemView.findViewById(R.id.category_button);
}
}
}