Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active Dec 28, 2017
Embed
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;
}
@Override
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);
}
@Override
public void onBindViewHolder(RouteViewHolder holder, int position) {
holder.bind(position);
}
@Override
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