Android Basics – Create the basic Adapter for RecyclerView

To create a basic Adapter which can be used by the RecyclerView create a new class and extend RecyclerView.Adapter

Once you do this you need to override the following three methods

  • The getItemCount method is used to return the number of items in the data set.
  • The onCreateViewHolder method is used to create the views.
  • The onBindViewHolder method is used to bind views to data.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return null;
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

}

@Override
public int getItemCount() {
    return 0;
}

Source Code is available here

Author: androidsmartly

I am a Tech Enthusiast who likes to work on new Ideas. Sharing knowledge on Android, Marketing, Startups and More.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s