I am unable to override onviewcreated method for fragment
this is my code
import androidx.lifecycle.ViewModelProviders
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.ab.R
class HomeFragment : Fragment() {
companion object {
fun newInstance() = HomeFragment()
}
private lateinit var viewModel: HomeViewModel
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.home_fragment, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
viewModel = ViewModelProviders.of(this).get(HomeViewModel::class.java)
// TODO: Use the ViewModel
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
}
Redundant overriding method less... Inspection info: This inspection reports redundant override modifiers which can be omitted
Android studio, when using Kotlin, will show this for most redundant overrides and therefore you can entirely delete these overrides, as they don't do anything (besides calling super methods) anyway. Adding additional logic and code in to these overrides will stop the issues, as I said in my comment, just making an answer to be complete.