Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////////////////////////////////////////////////////////////////////////////////
- // ContentListFragment
- ////////////////////////////////////////////////////////////////////////////////
- private int mBookTypeId;
- private final static String BOOK_TYPE_ID = "BOOKTYPE_ID";
- public ContentListFragment() {}
- /**
- * Returns a new instance of this fragment for the given section number.
- */
- public static ContentListFragment newInstance(int bookTypeId) {
- ContentListFragment fragment = new ContentListFragment();
- Bundle args = new Bundle();
- args.putInt(BOOK_TYPE_ID, bookTypeId);
- fragment.setArguments(args);
- return fragment;
- }
- /**
- * This method will only be called once when the retained Fragment is first
- * created.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setRetainInstance(true);
- Bundle args = getArguments();
- mBookTypeId = args.getInt(BOOK_TYPE_ID);
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////////////
- // MainActivity
- ////////////////////////////////////////////////////////////////////////////////////////////////////////
- int mBookNumber = 1;
- public static final String CONTENT_LIST_FRAGMENT_TAG = "ContentListFragment";
- private FragmentTransaction mFragmentTransaction = null;
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- if (savedInstanceState == null) {
- mFragmentTransaction = getSupportFragmentManager().beginTransaction();
- mFragmentTransaction.replace(R.id.content_frame,
- ContentListFragment.newInstance(mBookNumber),
- CONTENT_LIST_FRAGMENT_TAG);
- mFragmentTransaction.commit();
- }
- }
Add Comment
Please, Sign In to add comment