title: How to show RecyclerView in the snippet with Firebase Realtime Database in Kotlin
body: <p>I have a problem with RecyclerView which takes data from Firebase.</p>
  <p>I know there are a lot of similar questions, but I can't find a correct solution to this problem. I think I have all the code enough to do what belongs but something is not working. When I open my application I get the error:</p>
  <pre><code>&quot;E / RecyclerView: No adapter attached; skipping layout&quot;.
  </code></pre>
  <p>Here is my fragment class:</p>
  <pre><code>class ExploreFragment : Fragment() {
  
      var fragmentView : View? = null
      var mSearchText : EditText? = null
      var mRecyclerView : RecyclerView? = null
      var mButton : ImageButton? = null
  
      var mDatabase : DatabaseReference? = null
  
      var FirebaseRecyclerAdapter : FirebaseRecyclerAdapter&lt;Users1 , UsersViewHolder&gt;? = null
  
      override fun onCreateView(
          inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?
  
  
      ): View? {
  
          fragmentView = LayoutInflater.from(activity).inflate(R.layout.fragment_explore, container, false)
  
          mSearchText = view?.findViewById(R.id.search_edit_text)
  
          mButton = view?.findViewById(R.id.search_btn)
  
          mRecyclerView = view?.findViewById(R.id.recycler_view_search)
          mRecyclerView?.setHasFixedSize(true)
          mRecyclerView?.layoutManager = LinearLayoutManager(context)
  
          mDatabase = FirebaseDatabase.getInstance().getReference(&quot;Users&quot;)
  
  
  
          mSearchText?.addTextChangedListener(object  : TextWatcher {
              override fun afterTextChanged(p0: Editable?) {
  
              }
  
              override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
              }
  
              override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
  
                  val searchText = mSearchText?.getText().toString().trim()
  
                  loadFirebaseData(searchText)
              }
          } )
  
  
          return fragmentView
      }
  
      private fun loadFirebaseData(searchText : String) {
  
          if(searchText.isEmpty()){
  
              FirebaseRecyclerAdapter?.cleanup()
              mRecyclerView?.adapter = FirebaseRecyclerAdapter
  
          }else {
  
  
              val firebaseSearchQuery = mDatabase?.orderByChild(&quot;username&quot;)?.startAt(searchText)?.endAt(searchText + &quot;\uf8ff&quot;)
  
              FirebaseRecyclerAdapter = object : FirebaseRecyclerAdapter&lt;Users1, UsersViewHolder&gt;(
  
                  Users1::class.java,
                  R.layout.layout_list,
                  UsersViewHolder::class.java,
                  firebaseSearchQuery
              ){
                  override fun populateViewHolder(viewHolder: UsersViewHolder, model: Users1?, position: Int) {
  
                      viewHolder.mview.userName.setText(model?.name)
  
                  }
  
              }
  
              mRecyclerView?.adapter = FirebaseRecyclerAdapter
  
          }
      }
  
  companion object {
         @JvmStatic
          fun newInstance() =
              ExploreFragment().apply {
                  arguments = Bundle().apply {}
              }
      }
      class UsersViewHolder(var mview : View) : RecyclerView.ViewHolder(mview) {
  
      }
  }
  </code></pre>
  <p>Here is my layout:</p>
  <pre><code>&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      android:gravity=&quot;center&quot;&gt;
  
  
  
      &lt;com.google.android.material.appbar.AppBarLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:id=&quot;@+id/app_bar_layout_search&quot;&gt;
  
          &lt;androidx.appcompat.widget.Toolbar
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_marginTop=&quot;4dp&quot;
              android:layout_marginLeft=&quot;6dp&quot;
              android:layout_marginRight=&quot;6dp&quot;
              android:background=&quot;@android:color/white&quot;
              android:id=&quot;@+id/search_toolbar&quot;&gt;
  
              &lt;RelativeLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;&gt;
  
  
                  &lt;EditText
                      android:id=&quot;@+id/search_edit_text&quot;
                      android:layout_width=&quot;297dp&quot;
                      android:layout_height=&quot;45dp&quot;
                      android:layout_marginTop=&quot;5dp&quot;
                      android:layout_marginEnd=&quot;13dp&quot;
                      android:layout_marginRight=&quot;60dp&quot;
                      android:layout_toStartOf=&quot;@+id/search_btn&quot;
                      android:background=&quot;@drawable/search_layout&quot;
                      android:ems=&quot;20&quot;
                      android:hint=&quot;Search here&quot;
                      android:inputType=&quot;textPersonName&quot;
                      android:paddingLeft=&quot;20dp&quot;
                      android:paddingTop=&quot;10dp&quot;
                      android:paddingRight=&quot;20dp&quot;
                      android:paddingBottom=&quot;10dp&quot;
                      android:textColor=&quot;#999999&quot;
                      android:textSize=&quot;10sp&quot; /&gt;
  
                  &lt;ImageButton
                      android:id=&quot;@+id/search_btn&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_alignTop=&quot;@+id/search_edit_text&quot;
                      android:layout_alignBottom=&quot;@+id/search_edit_text&quot;
                      android:layout_alignParentEnd=&quot;true&quot;
                      android:layout_marginTop=&quot;0dp&quot;
                      android:layout_marginEnd=&quot;34dp&quot;
                      android:layout_marginRight=&quot;30dp&quot;
                      android:layout_marginBottom=&quot;-1dp&quot;
                      android:background=&quot;@android:color/background_light&quot;
                      app:srcCompat=&quot;@mipmap/search_button&quot; /&gt;
  
  
              &lt;/RelativeLayout&gt;
  
          &lt;/androidx.appcompat.widget.Toolbar&gt;
  
      &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
      &lt;androidx.viewpager2.widget.ViewPager2
          android:id=&quot;@+id/viewPagerImageSlider&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:paddingStart=&quot;80dp&quot;
          android:paddingEnd=&quot;80dp&quot; /&gt;
  
      &lt;androidx.recyclerview.widget.RecyclerView
          android:id=&quot;@+id/recycler_view_search&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:layout_below=&quot;@id/app_bar_layout_search&quot;&gt;
  
      &lt;/androidx.recyclerview.widget.RecyclerView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>Here is my Users1 class:</p>
  <pre><code>class Users1 {
      var name: String? = null
      var image: String? = null
  
      constructor() {}
  
      constructor(name: String?, image: String?) {
          this.name = name
          this.image = image
      }
  }
  </code></pre>