Is there any way I can check if a certain layout ID exists before using it with setContentView(R.layout.mylayoutid)?
Something like:
if(layout_exists(\"m
Yes, there is.
int layoutId = getContext().getResources().getIdentifier("mylayoutid","layout", getContext().getPackageName());
if (layoutId == 0){
// this layout doesn't exist
} else {
setContentView(layoutId);
}
As it is a static integer in the R.java
file you can't compile your app, if it does not exist.