Bianca Nunes
Bianca Nunes

Reputation: 1

Abstract class created in an unconventional way

Please, I need your help.

About this abstract class in Android Studio:

public abstract static class Adapter<VH extends RecyclerView.ViewHolder> 

Are there any Java books that explain this?

I've never seen an abstract class being created this way. Using these symbols: <> And within these symbols, there are an extend method. I've never seen before.

Does anyone know some book that explains about this kind of abstract class?

Upvotes: 0

Views: 48

Answers (2)

Bianca Nunes
Bianca Nunes

Reputation: 1

Thank you for responding.

So it's only in Android programming that there is this kind of abstract class?

This kind of programming, which I have never seen before, I think it's quite complex.

I had already seen the Android's documentation, containing this information that you passed me. But I found it difficult to understand.

Upvotes: 0

Hyun I Kim
Hyun I Kim

Reputation: 589

That Adapter class is an abstract class that you have to implement to use RecyclerView.

So you shouldn't leave it as abstract unless you are going to make a child class of it and implement again.

It basically means that

It is an abstract class that uses VH as generic type.

So you will write something like

public class MyAdapter extends Adapter<MyViewHolder> {

Then there are three methods you have to override.

  1. MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
  2. void onBindViewHolder(MyViewHolder holder, int position)
  3. int getItemCount()

You can find android recyclerview implementation example here.

Upvotes: 1

Related Questions