Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.3版本改了什么地方啊,一样的代码,使用2.2.3版本加载不出图片,发现是onCreateHolder都没调用,但是改用2.2.2就行 #1238

Open
zpszz opened this issue Aug 23, 2024 · 1 comment

Comments

@zpszz
Copy link

zpszz commented Aug 23, 2024

class HomeBannerAdapter(dataList: ArrayList<BannerData>): BannerAdapter<BannerData, HomeBannerAdapter.BannerViewHolder>(dataList){

    inner class BannerViewHolder(var imageView: ImageView): RecyclerView.ViewHolder(imageView)

    override fun onCreateHolder(parent: ViewGroup?, viewType: Int): BannerViewHolder {
        val imageView = ImageView(parent?.context)
        // 必须设置为match_parent,这是ViewPager2强制要求的
        imageView.layoutParams = ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT,
        )
        imageView.scaleType = ImageView.ScaleType.CENTER_CROP
        return BannerViewHolder(imageView)
    }

    override fun onBindView(
        holder: BannerViewHolder,
        data: BannerData,
        position: Int,
        size: Int
    ) {
        LogUtil.d("HomeBannerAdapter", data.pic)
        holder.imageView.apply {
            LogUtil.d("HomeBannerAdapter", data.pic)
            load(data.pic)
            // 点击跳转
        }
    }
}
banner.apply {
                setAdapter(mBannerAdapter)
                indicator = CircleIndicator(context)
                addBannerLifecycleObserver(viewLifecycleOwner)
            }

项目一些版本配置如下

compileSdk = "34"
targetSdk = "34"
minSdk = "29"
versionCode = "1"
versionName = "1.0"
java = "VERSION_17"
ksp = "1.9.22-1.0.17"
agp = "8.5.1"
kotlin = "1.9.22"
@wangjingchun
Copy link

QQ20240829-165047@2x 加一行这个就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants