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
mList = new ArrayList<>();
recycler_view.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
mRecyclerAdapter = new RecyclerAdapter();
recycler_view.setAdapter(mRecyclerAdapter);
recycler_view.setItemAnimator(new DefaultItemAnimator());
 
public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.ViewHolder> {
    public RecyclerAdapter() {
 
    }
 
    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.bld_row, parent, false);
        return new ViewHolder(view);
    }
 
    @Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
        holder.bldName.setText(mList.get(position));
    }
 
    @Override
    public int getItemCount() {
        return mList.size();
    }
 
    public class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.bld_name) TextView bldName;
 
        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
 
    }
}
cs

+ Recent posts