NumberViewHolder viewHolder = new NumberViewHolder(view);
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us. * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(NumberViewHolder holder, int position) { Log.d(TAG, "#" + position); holder.bind(position); }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount); int backgroundColorForViewHolder = ColorUtils .getViewHolderBackgroundColorFromInstance(context, viewHolderCount); viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder); viewHolderCount++; Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: " + viewHolderCount); return viewHolder; }
NumberViewHolder viewHolder = new NumberViewHolder(view);
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us. * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(NumberViewHolder holder, int position) { Log.d(TAG, "#" + position); holder.bind(position); }
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us. * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(NumberViewHolder holder, int position) { Log.d(TAG, "#" + position); holder.bind(position); }
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us. * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(NumberViewHolder holder, int position) { Log.d(TAG, "#" + position); holder.bind(position); }
@Override public void onBindViewHolder(NumberViewHolder holder, int position) { holder.bind(position); }
@Override public void onClick(View view) { mOnClickListener.onListItemClick(getAdapterPosition()); } }
@Override public NumberViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { Context context = parent.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); Boolean shouldAttachToParentInmediatly = false; View view = inflater.inflate(layoutIdForListItem, parent, shouldAttachToParentInmediatly); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount); int backgroundColorForViewHolder = ColorUtils .getViewHolderBackgroundColorFromInstance(context, viewHolderCount); viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder); viewHolderCount++; Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: " + viewHolderCount); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount); int backgroundColorForViewHolder = ColorUtils .getViewHolderBackgroundColorFromInstance(context, viewHolderCount); viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder); viewHolderCount++; Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: " + viewHolderCount); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); viewHolder.viewHolderIndex.setText("ViewHolder index: " + viewHolderCount); int backgroundColorForViewHolder = ColorUtils .getViewHolderBackgroundColorFromInstance(context, viewHolderCount); viewHolder.itemView.setBackgroundColor(backgroundColorForViewHolder); viewHolderCount++; Log.d(TAG, "onCreateViewHolder: number of ViewHolders created: " + viewHolderCount); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details. * @return A new NumberViewHolder that holds the View for each list item */ @Override public NumberViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); int layoutIdForListItem = R.layout.number_list_item; LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; View view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); NumberViewHolder viewHolder = new NumberViewHolder(view); return viewHolder; }
/** * OnBindViewHolder is called by the RecyclerView to display the data at the specified * position. In this method, we update the contents of the ViewHolder to display the correct * indices in the list for this particular position, using the "position" argument that is conveniently * passed into us. * * @param holder The ViewHolder which should be updated to represent the contents of the * item at the given position in the data set. * @param position The position of the item within the adapter's data set. */ @Override public void onBindViewHolder(NumberViewHolder holder, int position) { Log.d(TAG, "#" + position); holder.bind(position); }