B
B
BitNeBolt2020-08-30 07:36:25
Android
BitNeBolt, 2020-08-30 07:36:25

Why is there a slight lag when flipping fragments?

There are 2 tabs that the user must scroll through. I do them with Viewpager2 and FragmentStateAdater. Each of the fragments located in Viewpager2 has a Recyclerview that needs to be filled with different data.

I asynchronously receive data (for two fragments at once) from the base (local) in the activity method and pass it to the adapter during initialization.

Each list element from the second tab has 4 text fields, about a hundred characters in total, there are about 20 list elements so far, but the user has no restrictions on their creation (to the issue of performance).

Why is there a lag when switching tabs for the first time?

Ps When I took data for each fragment asynchronously in its life cycle, there was a lag, but it looked different. I don't know anything about Livedata.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alekseyHunter, 2020-08-30
@alekseyHunter

Code and circuses to us.
In what method are you initializing?
That's right, the adapter Stores the current tab and one each left/right. It created the tabs and keeps them in memory, so after the first initialization there is no lag, if you tell the adapter to redraw the tabs every time, there will be lags all the time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question