-1

I realize that the guide for create a List with Recycler View https://developer.android.com/guide/topics/ui/layout/recyclerview

In the part ViewHolder,they are using "public MyViewHolder (TextView textView)"

But when I look at another example,they are using "MyViewHolder(View itemView)"

Is there any different?

Jin9782
  • 39
  • 4

2 Answers2

-1

TextView is a subclass of View. View represents the basic building block for user interface components. View is the base class for widgets, which are used to create interactive UI components (like text fields).The View should be your TextView.

if( view instanceof TextView ) {
  TextView textView = (TextView) view;
  //Do your stuff
}
Sultan Mahmud
  • 1,245
  • 8
  • 18
-2

A Textview will only allow you to show text (and it should not be editable). A view is the superclass of the Textview. So you can do:

View textview = new TextView()

But you could also use another type of view, which would allow you to display something else than text

Astrogat
  • 1,617
  • 12
  • 24