Closed DJDrama closed 4 years ago
Don't quite get what you mean. Can you paste your code?
vpAdapter = ViewPagerAdapter(activity!!, vpList, true) vp_auto_rolling.adapter = vpAdapter
internal class ViewPagerAdapter(
context: Context,
itemList: java.util.ArrayList
override fun inflateView(viewType: Int, container: ViewGroup, listPosition: Int): View {
return LayoutInflater.from(context).inflate(R.layout.vp_item_image, container, false)
}
override fun bindView(convertView: View, listPosition: Int, viewType: Int) {
val ivItem = convertView.findViewById<ImageView>(R.id.iv_vp_item)
Glide.with(context)
.load(itemList[listPosition].image_url)
.centerCrop()
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into(ivItem)
}
override fun getCount(): Int {
return itemList.size
}
}
this is it! I am using Kotlin by the way. vplist is just a custom datatype ArrayList
Sorry that I missed this issue for a long time.
Not sure if you still need help, but the problem is because you override getCount() in your adapter. If you check its parent you will see it has special handling.
Remove that override and the issue should be solved.
@siralam Thanks for the reply. Yeah i already solved that issue before. But still glad to hear from you! have a nice day
For ex, i have 5 items and this viewpager at first load, shows 5 items (autoloop and inifite both true).
When it reaches the last item, it just jump immediately to the second item, and loops again. it never shows the first item any more, and also the last item is not visible to the users since the viewpager pops to the second index (thinking the second index as the first index, and ignoring the last index)