Android Kotlin: “overrides nothing” error appears on instantiateItem() function of PagerAdapter

I just began learning Kotlin for work and one of the first errors I encountered is “overrides nothing” pointing at the overrides of the function instantiateItem() for my PagerAdapter

The function/method signature was like this:

override fun instantiateItem(parent: ViewGroup?, position: Int): Any {

To fix the error, I simply removed the question mark from the arguments so that it looked like:

override fun instantiateItem(parent: ViewGroup, position: Int): Any {

Voila! Error gone and the swipe view that needed the PagerAdapter worked.

Reference: Sudden “overrides nothing” errors appear, no recent change to Kotlin build version

Related Posts:

Posts that may be related to "Android Kotlin: “overrides nothing” error appears on instantiateItem() function of PagerAdapter":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *