Code example for Fragment

Methods: getArgumentsonCreate

0
        /** 
         * When creating, retrieve this instance's number from its arguments. 
         */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Bundle args = getArguments();
            mNum = args != null ? args.getInt("num") : 1;
        } 
 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            // Set up the various ad layouts on different flip pages. 
            final int[] layouts = {
                    R.layout.ad_top, 
                    R.layout.ad_bottom, 
                    R.layout.ad_next_to_button, 
                    R.layout.ad_covers_content }; 
            int layoutId = layouts[mNum];
            View v = inflater.inflate(layoutId, container, false);