# Your Second Kotlin Android App - Part 4: Setting up a | Ray Wenderlich

**URL:** <https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 24, 2018, 2:47am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718 "2018-03-24T02:47:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [March 24, 2018, 2:47am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/1 "2018-03-24T02:47:43Z")

</div>

Having a RecyclerView isn't enough. You also need an adapter. Learn about adapters in this video.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/4534-your-second-kotlin-android-app/lessons/4](https://www.raywenderlich.com/4534-your-second-kotlin-android-app/lessons/4)

---

<div class="post-metadata">

**Author:** ![davidvpe](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/davidvpe/32/82438_2.png) [@davidvpe](https://forums.kodeco.com/u/davidvpe)\
**Post date:** [October 27, 2018, 6:10am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/2 "2018-10-27T06:10:30Z")

</div>

Hi @bdmoakley !

It might be my Android version but I saw that on the `MainActivity` there are two variables: `fab` and `toolbar` that are not declared and assigned through `findViewById` but auto-referenced with the import:

`import kotlinx.android.synthetic.main.activity_main.*`

So the question is:  
Which way is more efficient than the other?

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [October 29, 2018, 12:40pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/3 "2018-10-29T12:40:20Z")

</div>

Hey @macsimus, any thoughts on this? Cheers! Brian

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [October 31, 2018, 2:38am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/4 "2018-10-31T02:38:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![macsimus](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/macsimus/32/109104_2.png) [@macsimus](https://forums.kodeco.com/u/macsimus)\
**Post date:** [November 3, 2018, 5:51pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/5 "2018-11-03T17:51:48Z")

</div>

Hi David and Brian!

Those views are referenced using Kotlin Android Extensions. You can read more about KAE here: [https://www.raywenderlich.com/84-kotlin-android-extensions](https://www.raywenderlich.com/84-kotlin-android-extensions)

Kotlin Android Extensions utilize a cache and so it’s possible they can be more efficient than using `findViewByID()`. The best part is you need less code to reference your views, so they are definitely more efficient from a developer-perspective.

---

<div class="post-metadata">

**Author:** ![telornaga](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@telornaga](https://forums.kodeco.com/u/telornaga)\
**Post date:** [December 16, 2018, 3:01pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/6 "2018-12-16T15:01:45Z")

</div>

Hi, I use latest Android Studio, and when type

```
class ListSelectionViewHolder(itemView: View?) : RecyclerView.ViewHolder(itemView)

```

has error : type mismatch, required `View` found `View?`, then I change it to just `View`. Is there any explaination for this since in the view no problem.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [December 28, 2018, 8:24pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/7 "2018-12-28T20:24:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![macsimus](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/macsimus/32/109104_2.png) [@macsimus](https://forums.kodeco.com/u/macsimus)\
**Post date:** [December 28, 2018, 8:35pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/8 "2018-12-28T20:35:07Z")

</div>

Thanks for the question @telornaga!

As the Android SDK and support libraries evolve, Google has been adding nullability annotations into the Java code. So it will sometimes happen that a constructor, like that here for RecyclerView.ViewHolder, goes from taking a nullable parameter to needing a non-nullable parameter. That seems to be what happened here. You’ll also see this sometimes when you use Ctrl+I to add shells for overrides for an interface you’re implementing, and need to make the parameters non-nullable.

I hope that helps. Thanks again!

---

<div class="post-metadata">

**Author:** ![ankm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ankm/32/81494_2.png) [@ankm](https://forums.kodeco.com/u/ankm)\
**Post date:** [December 13, 2019, 9:37am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/10 "2019-12-13T09:37:23Z")

</div>

@bdmoakley this causing App crash because is not null safe i think so , so what is the solution of it.  
Am using android studio 3.5.3.  
And even the solution from @macsimus in the below is not working

---

<div class="post-metadata">

**Author:** ![ankm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ankm/32/81494_2.png) [@ankm](https://forums.kodeco.com/u/ankm)\
**Post date:** [December 13, 2019, 10:44am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/11 "2019-12-13T10:44:26Z")

</div>

@bdmoakley @macsimus

just removed TODO() from the method

```
indent preformatted text by 4 spaces override fun onBindViewHolder(holder: ListSelectionViewHolder, position: Int) {

}

```

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [December 13, 2019, 2:33pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/12 "2019-12-13T14:33:37Z")

</div>

What’s the complete code for your method?

---

<div class="post-metadata">

**Author:** ![ankm](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/ankm/32/81494_2.png) [@ankm](https://forums.kodeco.com/u/ankm)\
**Post date:** [December 13, 2019, 8:15pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/14 "2019-12-13T20:15:22Z")

</div>

It was empty but now it has the below

```
indent preformatted text by 4 spaces if (holder != null)
    {
        holder.listpostion.text = (position + 1).toString()
        holder.listTitle.text = listTitles[position] //since it will pass every index so the array will read it one by one
    }

```

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [January 13, 2020, 11:56pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/15 "2020-01-13T23:56:32Z")

</div>

@ankm What error do you get exactly?

---

<div class="post-metadata">

**Author:** ![karldusenbery](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/karldusenbery/32/87588_2.png) [@karldusenbery](https://forums.kodeco.com/u/karldusenbery)\
**Post date:** [February 12, 2020, 9:11am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/16 "2020-02-12T09:11:06Z")

</div>

I will go ahead and change the nullable View? to a non-nullable View like @telornaga suggested and see what happens later. Crossing my fingers that I don’t get an app crash later like what happened to @bdmoakley. I am also on Android Studio 3.5.3.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [March 31, 2020, 3:18am UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/18 "2020-03-31T03:18:16Z")

</div>

@karldusenbery Do you still have issues with this?

---

<div class="post-metadata">

**Author:** ![bdmoakley](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/bdmoakley/32/108772_2.png) [@bdmoakley](https://forums.kodeco.com/u/bdmoakley)\
**Post date:** [April 1, 2020, 2:32pm UTC](https://forums.kodeco.com/t/your-second-kotlin-android-app-part-4-setting-up-a-ray-wenderlich/40718/19 "2020-04-01T14:32:41Z")

</div>

This course is out of date - it probably causes some minor issues with Android Studio 3.5 - you can find our latest version over here: [https://www.raywenderlich.com/7503473-your-second-kotlin-android-app](https://www.raywenderlich.com/7503473-your-second-kotlin-android-app)
