I'm trying to do this in a library project...
int containerViewId = getResources().getIdentifier("content", "android.R.id", getPackageName());
getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();
But I get this exception on the replace: Caused by: java.lang.IllegalArgumentException: Must use non-zero containerViewId
How do I get resource id for android.R.id.content programmatically?
Thanks.
Edit: I have solved it by using a named view, setting the id in the xml layout of the activity and using the following code to replace the root view...
int containerViewId = getResources().getIdentifier("rootView", "id", getPackageName());
getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();
I have solved it by using a named view, setting the id in the xml layout of the activity and using the following code to replace the root view...
int containerViewId = getResources().getIdentifier("rootView", "id", getPackageName());
getFragmentManager().beginTransaction().replace(containerViewId, new SettingsFragment()).commit();