Your Second Kotlin Android App - Part 7: Challenge: | Ray Wenderlich

With your RecyclerView in place, the only thing left to do is present the data which just happens to be your challenge.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4534-your-second-kotlin-android-app/lessons/7

I am stuck at 4 errors.

  1. Class ‘ListSelectionRecyclerAdapter’ is not abstract and does not implement abstract base class member public abstract fun onBindViewHolder(@NonNull p0: ListSelectionViewHolder, p1: Int): Unit defined in android.support.v7.widget.RecyclerView.Adapter
  2. ‘onBindViewHolder’ overrides nothing
  3. ‘onCreateViewHolder’ overrides nothing
  4. Type mismatch: inferred type is View? but View was expected > Task :app.buildinforgeneratorDebug.

I cannot move forward. Please support

Hi Tinjothomasc

Can you post your code snippet? I’ll be happy to help to solve your error.

I know the first error is because when you extend the RecyclerView.Adapter, you need to pass in what type of Viewholder will this adapter deal with.

Example
If you do this, it will cause the first error you wrote:

class ListSelectionRecyclerViewAdapter : RecyclerView.Adapter<>() {

You need to mention ListSelectionViewHolder in the angular brackets after the Adapter when inheriting that class

class ListSelectionRecyclerViewAdapter : RecyclerView.Adapter<ListSelectionViewHolder>() {

In fact, for now I remove all the nullable question marks and it works. Do we really need those nullable things here?
And one more thing, the first item goes under the top green bar and not in view.

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hello @bdmoakley, I am also stuck at this code, the nullable operators do not work and throw an error same as you said @tinjothomasc required itemView, found itemView?.
The error in ListSelectionAdapter class does go away when you put itemView!! not null assertion operator at the end but then the error happens in ViewHolder class which complains not implementing methods (not nullable ones)

But I don’t understand why the error not caused in the code on screen?

Thanks,
Henna

@bdmoakley Do you have any feedback about this? Thank you - much appreciated! :]

required itemView , found itemView? .
I had the same error above at runtime. I had to remove the ‘?’ on View to make it no longer nullable to get it to work.

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

This course is out of date. To see the updated version, head over here: https://www.raywenderlich.com/7503473-your-second-kotlin-android-app