Android : Jetpack Compose - How to remove a page from HorizontalPager?

266 Views Asked by At

So here's my HorizontalPager declaration

HorizontalPager(state = pagerState, beyondBoundsPageCount = 3)

My pagerSate is

var pagerState = rememberPagerState(
        initialPage = currentArticleIndex, initialPageOffsetFraction = 0f
    ) {
        itemList.size
    }

Now when I am removing an item, let's say 3rd item from 10 items, then it's removed and the page is navigated to its previous page, i.e. 2nd page. But then again when I am trying to remove an item, it's not removing, nothing is working. It works only one time.

Also, HorizontalPager is navigated to its previous page automatically when I am removing an item, but it's not navigating to next page when the first item (0th index) is removed.

This is weird from Jetpack Compose. I want to disable that automatic navigation on deleting an item.

Any help will be really appreciated!

0

There are 0 best solutions below