Search code examples
kotlinmethodsandroid-recyclerviewoverridingandroid-arrayadapter

How to declare two types of layout access one method first one (Post) next( Ads) using one method in adapter class


Is there possibility to have post and ads methods in two class based view?

I tried to do something like this but of course it doesn't work and error it not working (layout ads) Id

enter image description here


Solution

  • In line 55, change HolderProduct to RecyclerView.ViewHolder, and also in your NewpostAdapter class declaration change the ViewHolder type from HolderProduct to RecyclerView.ViewHolder. Then adjust overriden methods accordingly.