|
| 1 | +package com.example.android.dailygoals; |
| 2 | + |
| 3 | +import android.content.Context; |
| 4 | +import android.support.v7.widget.RecyclerView; |
| 5 | +import android.view.LayoutInflater; |
| 6 | +import android.view.View; |
| 7 | +import android.view.ViewGroup; |
| 8 | +import android.widget.ImageView; |
| 9 | +import android.widget.TextView; |
| 10 | + |
| 11 | +import java.util.ArrayList; |
| 12 | + |
| 13 | +public class TextAdapter1 extends RecyclerView.Adapter<TextAdapter1.ViewHolder> { |
| 14 | + |
| 15 | + private Context mcontext; |
| 16 | + private ArrayList<Items1> item1List; |
| 17 | + |
| 18 | + |
| 19 | + TextAdapter1(Context context,ArrayList<Items1> list){ |
| 20 | + mcontext=context; |
| 21 | + item1List=list; |
| 22 | + |
| 23 | + } |
| 24 | + @Override |
| 25 | + public ViewHolder onCreateViewHolder(ViewGroup parent,int ViewType){ |
| 26 | + |
| 27 | + LayoutInflater layoutInflater=LayoutInflater.from(mcontext); |
| 28 | + View view=layoutInflater.inflate(R.layout.items1,parent,false); |
| 29 | + ViewHolder viewHolder=new ViewHolder(view); |
| 30 | + return viewHolder; |
| 31 | + |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public void onBindViewHolder(ViewHolder holder, int position) { |
| 36 | + |
| 37 | + Items1 item=item1List.get(position); |
| 38 | + TextView text=holder.text1; |
| 39 | + text.setText(item.getText()); |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + @Override |
| 48 | + public int getItemCount() { |
| 49 | + return item1List.size(); |
| 50 | + } |
| 51 | + public class ViewHolder extends RecyclerView.ViewHolder{ |
| 52 | + |
| 53 | + TextView text1; |
| 54 | + |
| 55 | + public ViewHolder(View itemView){ |
| 56 | + super(itemView); |
| 57 | + text1=itemView.findViewById(R.id.text1); |
| 58 | + |
| 59 | + |
| 60 | + } |
| 61 | + } |
| 62 | +} |
| 63 | + |
0 commit comments