Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"onCreateView overrides nothing"

When I change the container type in my onCreateView() from Viewgroup? to Viewgroup I get this error:

enter image description here

Why is this?

like image 419
Zorgan Avatar asked May 18 '19 01:05

Zorgan


1 Answers

You are getting an error because ViewGroup is marked as nullable in the fragment parent class. In Kotlin '?' indicates that this value can be null in Kotlin. In Kotlin any variable can be either nullable or non-nullable. Kotlin provides compile-time error for nullability. You get compile time error if you try to assign null values to a non-nullable variable. You cannot make nullable parameter in parent class non-nullable in child class function intended as overridden function.

enter image description here

like image 184
v4_adi Avatar answered Sep 18 '22 06:09

v4_adi