I'm trying to make simple program that allows to "load" an .xml file and display it as the View in setContentView of a new activity. Basically, what I would like is that the view of the new activity would be the same as if I called
setContentView(R.layout.my_view)
where R.layout.my_view would be that xml file. But in my case, that file doesn't yet exist at compilation time, and should be loaded dynamically (e.g., from storage).
I guess I could parse my .xml file and build the view dynamically by code, but that feels like reinventing the wheel and it's also most likely that the views won't be identical. I thought there should be some easy way to do this, but all the methods I found so far from similar questions (e.g.,
getResources().getXml(R.layout.my_view);
//or
LayoutInflater.from(context).inflate(R.layout.my_view, null) )
seem to require the file already in compilation time. Is there something I'm missing?