How to get a value from resource file in the main Activity class when using fragments?
I’m developing an app with fragments and I want to use a value from “strings.xml” in MainActivity.kt. These are the names of the tabs. But, if I do this:
private var title: String = getText(R.string.title).toString()
I get this error when I run the code:
java.lang.NullPointerException: Attempt to invoke virtual method ‘android.content.res.Resources android.content.Context.getResources()’ on a null object reference
If I do:
private var title = getText(R.string.title)
I also get the error...