Documente Academic
Documente Profesional
Documente Cultură
SteveOne
• So the next day, the boss went and talk to the Steves
THE TALK
• Boss: “Look, I need you to do some
extra work for me, I need you too
tell me if a user has tapped on
your”
if (v == steveOne) {
// Waves of ads!
}
if (v == steveOne) {
// Waves of discounts that
nobody will ever care about!
}
}
SteveOne
onClick (View v)
Where v is steveTwo
Buy one
get one
free!
@override
Public void onClick(View v) {
if (v == steveOne) {
// Waves of ads!
}
if (v == steveOne) {
SteveTwo
// Waves of discounts that
@override
public void onBindViewHolder(ViewHolder holder, int position)
@override
public void onCreateViewHolder(Viewgroup parent, int viewtype)
@override
Side note, the public void getItemCount() method is the driving force for the public void getItemCount()
recyclerView. If you have 10 items in your data, but somehow you returned say
5 in that method, it will only display 5 items, the recyclerView only see the
returned integer as a source of truth in the number of items you truly have.
@override
public void onCreateViewHolder(Viewgroup parent, int viewtype) Exercise T03.07
The viewHolder you just The TextView handle you created in:
created
class ViewHolder extends RecyclerView.ViewHolder
Initialize the adapter using the data. For example:
RECAP
public GreenAdapter(int numberOfItems,
ListItemClickListener listener) {
mNumberItems = numberOfItems;
mOnClickListener = listener;
viewHolderCount = 0;
}
Recycler
Data Adapter View
(mNumberList)
Use the adapter to set the recyclerView. Remember, the recyclerView doesn’t
own the data, the adapter does. Simply put, the adapter provide the data and
the instruction on how a recyclerView should