Skip to content

Instantly share code, notes, and snippets.

Last active Dec 28, 2017
What would you like to do?
public class RoutesAdapter extends RecyclerView.Adapter<RoutesAdapter.RouteViewHolder> {
private static final String TAG = RoutesAdapter.class.getSimpleName();
private JSONArray mItems;
RoutesAdapter(JSONArray routes) {
mItems = routes;
public RouteViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
Context context = viewGroup.getContext();
int layoutIdForListItem = R.layout.route_list_item;
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(layoutIdForListItem, viewGroup, false);
return new RouteViewHolder(view);
public void onBindViewHolder(RouteViewHolder holder, int position) {
public int getItemCount() {
return mItems.length();
class RouteViewHolder extends RecyclerView.ViewHolder {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment