-3

I'm trying to show some list of items in a recyclerview, following the next article GIT REPO. I need to load 20 fake items before the recyclerview loads the next real items, as a loading. But I don´t know how to insert this cells and later.

Someone could give me a hand?

enter image description here

Víctor Martín
  • 3,352
  • 7
  • 48
  • 94

1 Answers1

0

"Fake" items are just "items" to RecyclerView – there's no difference between them. Hence to show them you'd have to use the same thing you use to show "ordinary" items in RecyclerViews: a RecyclerView.Adapter.

The component responsible for placeholder views like the one you've shown above is actually the activity/fragment containing the RecyclerView. Here's a rough illustration of how it might work:

  1. Make sure your adapter could handle (at least) 2 view types: one for your real view, one for the placeholder.

  2. Whenever you're loading your data, add null objects to your adapter's List.

  3. Configure your adapter to inflate a placeholder view whenever it's being asked to render a null object.

  4. When your data is loaded, replace those null objects with an actual object coming from your data store.

Hadi Satrio
  • 4,272
  • 2
  • 24
  • 45