0

While researching on the RecyclerView.Adapter class I came across this line of code:

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> 

I am aware of the underlying concept of Adapters and ViewHolders.But I am curious related to the Syntax "MyAdapter.ViewHolder".Is this kind of syntax used in java as well? I am just trying to understand why this piece lies in the Class Declaration? Thanks in advance

ghostrider
  • 2,046
  • 3
  • 23
  • 46

1 Answers1

1

MyAdapter.ViewHolder just means that you should implement your own ViewHolder in the MyAdapter class. For instance, if you had named the MyAdapter class, RandomAdapter then inside the <> you should put RandomAdapter.ViewHolder and within the RandomAdapter you should implement the ViewHolder

Check here Step 4

TheoK
  • 3,601
  • 5
  • 27
  • 37
  • What is the use of writing it in the class declaration, as I am going to anyways implement the View Holder in the Class.Why such a special treatment to ViewHolder only why not other custom classes that I may write inside the Adapter class? – ghostrider Jun 04 '15 at 07:09
  • 1
    Check the reference: http://developer.android.com/reference/android/support/v7/widget/RecyclerView.ViewHolder.html It just the way it is implemented in order to cooperate with the Adapter – TheoK Jun 04 '15 at 07:12