Getting some object from the layout file (say, test.xml) requiring setting this layout in the activity. For example if the button has an id “@+id/btn” then I can’t get it by findViewById(R.id.btn) because it throws NullPointerException, I have to set this layout as setContentLayout(test.xml) and only then get the button. The question is how can I get the object from layout file in a class which isn’t an activity => I can’t set layout there.
Getting some object from the layout file (say, test.xml) requiring setting this layout in
Share
you have to use an inflater:
take a look at the doc:
inflater
as class overview says