Reputation: 41858
In the last method I get
Type mismatch: inferred type is android.support.v4.app.Fragment
but android.app.Fragment! was expected
I am not certain how to resolve this in Kotlin.
var fragment: Fragment = null
var fragmentClass: Class<*>? = null
fragmentClass = CardBackFragment::class.java
try {
fragment = fragmentClass!!.newInstance() as Fragment
} catch (e: Exception) {
e.printStackTrace()
}
fragmentManager
.beginTransaction()
.replace(R.id.flContent, fragment)
Upvotes: 0
Views: 3232
Reputation: 843
Instead of using fragmentManager you need to use supportFragmentManager.
Upvotes: 10