Last active
December 27, 2016 17:17
-
-
Save budioktaviyan/6ed8a7e951e881bf3eece282d959c1c2 to your computer and use it in GitHub Desktop.
Home Adapter Class
This file contains 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
public class HomeAdapter extends RecyclerView.Adapter<HomeAdapter.HomeHolder> { | |
private final List<String> mItems; | |
public HomeAdapter(final List<String> items) { | |
mItems = items; | |
} | |
@Override | |
public HomeHolder onCreateViewHolder(final ViewGroup parent, final int viewType) { | |
final View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_home, parent, false); | |
return new HomeHolder(view); | |
} | |
@Override | |
public void onBindViewHolder(final HomeHolder holder, final int position) { | |
final String item = mItems.get(position); | |
holder.getTextView().setText(item); | |
} | |
@Override | |
public int getItemCount() { | |
return mItems.size(); | |
} | |
class HomeHolder extends RecyclerView.ViewHolder { | |
private final TextView mTextView; | |
public HomeHolder(final View itemView) { | |
super(itemView); | |
mTextView = (TextView) itemView.findViewById(R.id.tv_home); | |
} | |
public TextView getTextView() { | |
return mTextView; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment