Created
October 11, 2018 22:30
-
-
Save singhsegv/2e27b1cf67d0efdc63f921492d937dd7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package io.github.rajdeep1008.templatedemo; | |
| import android.content.Context; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import java.util.List; | |
| public class SchoolData extends RecyclerView.Adapter<SchoolData> { | |
| private final Context context; | |
| private List<SchoolItem> items; | |
| public SchoolData(List<SchoolItem> items, Context context) { | |
| this.items = items; | |
| this.context = context; | |
| } | |
| @Override | |
| public SchoolData onCreateViewHolder(ViewGroup parent, | |
| int viewType) { | |
| View v = LayoutInflater.from(parent.getContext()) | |
| .inflate(R.layout.R.layout.item_school, parent, false); | |
| return new SchoolData(v); | |
| } | |
| @Override | |
| public void onBindViewHolder(SchoolData holder, int position) { | |
| SchoolItem item = items.get(position); | |
| holder.set(item); | |
| } | |
| @Override | |
| public int getItemCount() { | |
| if (items == null) { | |
| return 0; | |
| } | |
| return items.size(); | |
| } | |
| public class SchoolData extends RecyclerView.ViewHolder { | |
| public SchoolData(View itemView) { | |
| super(itemView); | |
| } | |
| public void set(SchoolItem item) { | |
| //UI setting code | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment