setContentView - strange behavior if not using R.id.?
In my onCreate method for the first loaded Activity I have:
super.onCreate(savedInstanceState);
final int splash = R.layout.splash;
setContentView(splash);
This causes the app to crash. But if I use:
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
everything is fine. What gives?
The only reason I am experimenting with this is because I want to load different layouts based on a set of data-driven options that will come from another class dep开发者_开发问答ending on the customer's choices.
I'm having a hard time believing that's actually causing the crash. Can you provide the exception?
Most likely the other part of your code that's not pasted was trying to access resources of that content view BEFORE you had called setContentView()
.
精彩评论