-
Notifications
You must be signed in to change notification settings - Fork 59
与RecyclerView一起使用
Luke edited this page Feb 22, 2020
·
3 revisions
如果你要在RecyclerView中使用,你的Adapter应该这么写。
override fun onBindViewHolder(
holder: HostingViewHolder,
position: Int
) {
val page = pages[pos]
holder.hostingView.templatePage = page
}
override fun onViewRecycled(holder: HostingViewHolder) {
//下面这两行很关键,涉及到资源的正确回收,一定不能不写
holder.hostingView.unmountAllItems()
holder.hostingView.templatePage = null
}