How to change fragments using Android navigation drawer

后端 未结 5 1108
忘了有多久
忘了有多久 2020-11-30 22:43

I know these types of question have already been here but still I have not found my answer for this question:

  • I have created an application and used navigatio
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 23:09

    I solved this problem over inflater:

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState) {
            View rootView;
            switch(getArguments().getInt(ARG_SECTION_NUMBER)) {
                case 1:
                    rootView = inflater.inflate(R.layout.fragment_obj_detail, container, false);
                    break;
                case 2:
                    rootView = inflater.inflate(R.layout.fragment_obj_list, container, false);
                    break;
                case 3:
                    rootView = inflater.inflate(R.layout.fragment_obj_list, container, false);
                    break;
                case 4:
                    rootView = inflater.inflate(R.layout.fragment_about, container, false);
                    break;
                default:
                    rootView = inflater.inflate(R.layout.fragment_obj_list, container, false);
            }
            return rootView;
        }
    

提交回复
热议问题