I have a GenericContainer That extends an activity.
GenericContainer takes case of my fragments, i am using viewStubs to populate them.
How to implement nested fragments in GenericContainer. I will be opening stubOne first and then from stubOne I will be navigating to stubTwo. On clicking on back on stubTwo I should be coming back to stubOne.
GenericContainer
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_form_container);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
if(FormContainer.class.isAssignableFrom(getClass())) {
mToolbar.setNavigationIcon(R.drawable.ic_close_white_24px);
}
if(null != mStubForm.getParent()) {
int layoutId = getIntent().getExtras().getInt(AppConstants.KEY_STUB_LAYOUT_ID);
mStubForm.setLayoutResource(layoutId);
mStubForm.inflate();
}
}
I will open the STUB one and stubOno using the code below.
public void openStubOne(String title) {
Intent intent = new Intent(getActivity(), GenericContainer.class);
Bundle bundle = new Bundle();
bundle.putParcelable(KEY_SEARCH_OPTIONS, accountSearchEntity);
bundle.putInt(AppConstants.KEY_STUB_LAYOUT_ID, R.layout.layout_stub_ONE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivityForResult(intent, AppConstants.REQUEST_CODE_FORM_CONTAINER);
}
stubTwo
public void openStubTwo(String title) {
Intent intent = new Intent(getActivity(), GenericContainer.class);
Bundle bundle = new Bundle();
bundle.putString(AppConstants.KEY_SCREEN_TITLE, title);
bundle.putInt(AppConstants.KEY_STUB_LAYOUT_ID, R.layout.layout_stub_two);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
startActivityForResult(intent, AppConstants.REQUEST_CODE_FORM_CONTAINER);
}
Your help is much appreciated