Firebase:Recycler View No Adater Attached , Skipping Layout

Firebase : RecyclerView: No adapter attached; skipping layout

Based on the android life cycle callbacks, onStart() gets called only after onCreate(). And in your code, you tried to attach firebaseRecyclerAdapter to adapter before it was initialised.

If you wish to get rid from that annoying message, either you set empty adapter inside onCreate() or move all of your FirebaseRecyclerAdapter codes to onCreate and then set an adapter
.

Firebase :RecyclerView Skipping layout no Adapter Attached

I found the answer for this problem. In My xml File I've been using match_parent on the height. Which caused the main thread to skip the layout, because it couldn't find the layout scales.

So I changed the value to some standard height in dp. Eg: 600dp. Which defined the layout correctly so now the recyclerView is loading perfectly without skipping the layout.

my XML Code

`

   <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<androidx.recyclerview.widget.RecyclerView
android:id="@+id/myWorkListemp"

android:layout_width="match_parent"
android:layout_height="700dp"
android:layout_marginTop="15dp" />

<androidx.recyclerview.widget.RecyclerView
android:visibility="gone"

android:id="@+id/myCustomerListCustom"
android:layout_width="match_parent"
android:layout_height="700dp"
android:layout_marginTop="15dp" />

</LinearLayout>

`

E/RecyclerView: No adapter attached; skipping layout / Kotlin

That happens because the adapter is attached to the recycler after an asynchronous operation on onDrinkLoadSuccess

You can attach the adapter to the recycler during onCreate and then the onDrinkLoadSuccess update it with the data.

The ListAdapter class has a submit method for it. If you are using plain recycler is usually something like this:

Recycler ... {
private val dataList = mutableListOf()

fun update(list: List<YourType>) {
dataList.clear()
dataList.addAll(list)
notifyDataDetChanged() //important updates the UI
}
}

There are more specific updates methods like notifyItemRangeChanged, etc.

Also there are helpers for finding difference in the data sets DiffUtil.ItemCallback

No Adapter Attached Skipping layout error with RecyclerView Adapter

You are getting the following warning, not an error:

E/RecyclerView: No adapter attached; skipping layout

Because you are setting the adapter in a background thread. To solve this, you have to set the adapter outside the callback and inside it, just notify it about the changes. So please move the following lines of code:

journalRecyclerAdapter= new JournalRecyclerAdapter(JournalListActivity.this, journalist);
recyclerView.setAdapter(journalRecyclerAdapter);

Right after:

super.onStart();

And leave the following line as it is inside the callback:

journalRecyclerAdapter.notifyDataSetChanged();

And the warning will disapear.

Firebase to RecyclerView: No adapter attached; skipping layout

You are not able to see the text because your data/model class variable name is different than the key name store on firebase database

In logcat its showing this

No setter/field for ID found on class com.example.itachi.com.pab.Data (fields/setters are case sensitive!)
No setter/field for image found on class com.example.itachi.com.pab.Data
No setter/field for Name found on class com.example.itachi.com.pab.Data (fields/setters are case sensitive!)

Which cleary says that you should change the variable name in data class to match exact in your firebase database like this

public class Data {

// your varibale name is changed to match the firebase db

private String ID,Name,image;

public Data(){

}

public Data(String id, String name, String img) {
this.ID= id;
this.Name= name;
this.image= img;
}

public String getId() {
return ID;
}

public void setId(String id) {
this.ID= id;
}

public String getName() {
return Name;
}

public void setName(String name) {
this.Name = name;
}

public String getImg() {
return image;
}

public void setImg(String img) {
this.image= img;
}
}


Related Topics



Leave a reply



Submit