I am converting an Android app that was originally written in Java to Kotlin. I am struggling to understand the following error message:
Type mismatch. Required: MenuSlidingTabStrip.OnTabSelectedListener? Found: (Nothing, Nothing) → Boolean
Here is the fragment of code where the error is being signalled (and it was working perfectly fine before the conversion):
private var tabs: MenuSlidingTabStrip? = null //The Kotlinized class
tabs!!.setOnTabSelectedListner{ tab, category -> /*Type mismatch...*/
listView!!.post {
...
}
}
The issue arose after converting this Java code (found in MenuSlidingTabStrip) :
public void setOnTabSelectedListner(OnTabSelectedListener listener) {
this.listener = listener;
}
public interface OnTabSelectedListener {
public void OnTabSelected(View tab, MenuCategory category);
}
To Kotlin
fun setOnTabSelectedListner(listener: OnTabSelectedListener?) {
this.listener = listener
}
interface OnTabSelectedListener {
fun onTabSelected(tab: View?, category: MenuCategory?)
}
Can you see the issue? Do you need more code?