I have a text view in my Lyout and I would like to set some text to this textview. This should be made in a class which is not a MainActivity class.
The problem is t
When you call findViewById matters. The layout must have already happened. You must already have set a content view, etc.
There are ways to work around this, as shown in other answers, but they work fundamentally differently from findViewById, and should only be used as a substitute if you understand exactly how they work. Most often it's far more efficient to just wait until after the initial layout has already occurred.