I am trying to implement the following UI using ScrollableTabRow()
, HorizontalPager()
, and LazyColumn()
, where LazyColumn
will be available inside HorizontalPager
as a pageContent
.
So now the problem is when I swipe between pages of HorizontalPager
or when I select any tab from the ScrollableTabRow
, the pageContent (Text Composable in below code example) is called multiple times, and because of that, Composable LazyColum
(which is my actual implementation) is called multiple times.
I am looking for a solution where the content of HorizontalPager can be loaded only once.
See below the code of HorizontalPager and check println() which explains the issue.
HorizontalPager(
pageCount = tabList.size, state = pagerState
) { page ->
println("this line called multiple times when scrolled horizontally or any tab is selected")
Text(text = "this is the text with page no. $page")
}
Any help will be really appreciated.