title: NullPointerException for RecyclerView
body: <p>I have been recently starting to study and practice development for Android with Kotlin, for that I have been using a book from a Humble bundle from around a year ago, however until recently I was able to start on it, following each chapter there are certain apps to work on, for Recycler View there is an example with an app for Notes, after coding all clases, methods and functions needed I stood with this error and after checking multiple sources I am still unable to solve this, here is the line of code for the Main file</p>
  <pre><code>package com.gree.notas
  
  import android.os.Bundle
  import com.google.android.material.floatingactionbutton.FloatingActionButton
  import androidx.appcompat.app.AppCompatActivity
  import android.view.Menu
  import android.view.MenuItem
  import android.view.View
  import androidx.recyclerview.widget.DefaultItemAnimator
  import androidx.recyclerview.widget.DividerItemDecoration
  import androidx.recyclerview.widget.LinearLayoutManager
  import androidx.recyclerview.widget.RecyclerView
  
  class MainActivity : AppCompatActivity() {
  //private var notaTemporal = Notas()
  private val listaNotas = ArrayList&lt;Notas&gt;()
  private var recyclerView1: RecyclerView? = null
  private var adapter: AdaptadorNotas? = null
  
  fun crearNuevaNota(n: Notas){
      //notaTemporal = n
      listaNotas.add(n)
      adapter!!.notifyDataSetChanged()
  }
  
  fun mostrarNota(notaMostrar: Int){
      val dialogo = MostrarNota()
      dialogo.enviarNotaSeleccionada(listaNotas[notaMostrar])
      dialogo.show(supportFragmentManager, &quot;&quot;)
  }
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      setSupportActionBar(findViewById(R.id.toolbar))
  
      findViewById&lt;FloatingActionButton&gt;(R.id.fab).setOnClickListener { view -&gt;
          val dialogo = NuevaNota()
          dialogo.show(supportFragmentManager,&quot;&quot;)
      }
  
      recyclerView1 = findViewById&lt;View&gt;(R.id.recyclerView) as RecyclerView
      adapter = AdaptadorNotas(this, listaNotas)
      val layoutManager = LinearLayoutManager(applicationContext)
      recyclerView1!!.layoutManager = layoutManager
      recyclerView1!!.itemAnimator = DefaultItemAnimator()
      recyclerView1!!.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
      recyclerView1!!.adapter = adapter
  }
  
  override fun onCreateOptionsMenu(menu: Menu): Boolean {
      menuInflater.inflate(R.menu.menu_main, menu)
      return true
  }
  
  override fun onOptionsItemSelected(item: MenuItem): Boolean {
      return when (item.itemId) {
          R.id.action_settings -&gt; true
          else -&gt; super.onOptionsItemSelected(item)
      }
    }
  }
  </code></pre>
  <p>And here is the code for the Adapter class</p>
  <pre><code>package com.gree.notas
  
  import android.view.LayoutInflater
  import android.view.View
  import android.view.ViewGroup
  import android.widget.TextView
  import androidx.recyclerview.widget.RecyclerView
  
  class AdaptadorNotas(private val mainActivity: MainActivity, private val listaNotas: List&lt;Notas&gt;) : RecyclerView.Adapter&lt;AdaptadorNotas.ListItemHolder&gt;() {
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ListItemHolder {
      val itemView = LayoutInflater.from(parent.context).inflate(R.layout.lista, parent, false)
  
      return ListItemHolder(itemView)
  }
  
  override fun getItemCount(): Int {
      if(listaNotas != null){
          return listaNotas.size
      }
      return -1
  }
  
  override fun onBindViewHolder(holder: ListItemHolder, position: Int) {
      val nota = listaNotas!![position]
      holder.titulo.text = nota.titulo
  
      holder.descripcion.text = nota.descripcion!!.substring(0, 15)
      when{
          nota.idea -&gt; holder.estado.text = mainActivity.resources.getString(R.string.texto_idea)
          nota.importante -&gt; holder.estado.text = mainActivity.resources.getString(R.string.texto_importante)
          nota.porHacer -&gt; holder.estado.text = mainActivity.resources.getString(R.string.porhacer_texto)
      }
  }
  
  inner class ListItemHolder(view: View) :
      RecyclerView.ViewHolder(view), View.OnClickListener{
          internal var titulo = view.findViewById&lt;View&gt;(R.id.textViewTitle) as TextView
          internal var descripcion = view.findViewById&lt;View&gt;(R.id.textViewDescription) as TextView
          internal var estado =  view.findViewById&lt;View&gt;(R.id.textViewStatus) as TextView
          init {
              view.isClickable = true
              view.setOnClickListener(this)
          }
  
          override fun onClick(v: View?) {
              mainActivity.mostrarNota(adapterPosition)
          }
      }
   }
  </code></pre>
  <p>If somebody could help me find the root of the issue or show me what I should be looking for debugging and finding the right information for this NullPointerException <a href="https://i.stack.imgur.com/GMdar.jpg" rel="nofollow noreferrer">Exception on Build log</a>, will be really helpful</p>