0

So this isn't really a issue, I am just curious, do I really have to null check every time I use view binding? I find it a bit annoying having to put the question mark every time (binding?.[layout item]).

Can somebody please give me a solution to this if it's possible?

1 Answers1

0

The only reason you would be doing this is if you had marked the Binding object as nullable, e.g. lateinit var binding MainActivityBinding?. Which there is no need for.

Ivan Wooll
  • 4,145
  • 3
  • 23
  • 34
  • Oh yes, thanks! I totally forgot that every time I'm making the binding I am making it a nullable. I'm doing an android course and in the course the instructor does it that way, I guess I'll use the binding without making a nullable. – AbdullahCoder Jul 04 '23 at 05:14