I am new in learning kotlin and trying to start a android application project with it.
After I created a project, I got stuck in the first line of code I wrote..
So this is my code and error.
I made MainFragment class extend Fragment and passed it's instance to beginTransaction().add()
method.
I know that Fragment!
is a platform type and it is type of Java class instantiated.
But I think there is no reason Fragment
type doesn't math Fragment!
.
How do I solve this problem?
+) I also tried MainFragment() as Fragment
as FragmentTransaction won't Compile in Kotlin Android Project says, but it didn't work.
+) Also tried newInstance()
in companion object