Hello everyone, I’m developing an Android app usin...
# compose
s
Hello everyone, I’m developing an Android app using Jetpack Compose and need to insert an ad banner (AdView) within a LazyColumn. The ad banner should not be destroyed once it’s displayed until the screen is destroyed. However, since LazyColumn recycles its items, the AdView gets destroyed and recreated when it’s scrolled off-screen and back on-screen. Here’s a simplified version of my code:
Copy code
LazyColumn {
    items(itemsListA) { item ->
        A(item)
    }
    stickyHeader {
        B()
    }
    item {
        AdView()
    }
    items(itemsListC) { item ->
        C(item)
    }
}
Is there a way to prevent the AdView from being destroyed inside the LazyColumn?
e
a
You can also use PinnableContainer.
1
thank you frog 1
🛠️ 1
s
@Albert Chang I solved the problem using the PinnableContainer you mentioned. Thank you so much!
👍 1
c
wait. can I use pinnable container for this?!? https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1724079645043619
have a new project for this weekend 🤞
s
It looks like it's only used for lazy lists not just anywhere
c
oh darn.
132 Views