

現在こちらのコードを参考にアプリを作っています。（初心者です。）  
<https://github.com/rudsonlive/NavigationDrawer-MaterialDesign>

このDrawerMenuをクリックした時に、ListFragmentへ飛ばしたいのですが、何をどこに追記すればいいのでしょうか。  
例えば、menuの0、inboxをクリックした時にListFragmentへ飛ばすなど。  
お力添え頂けますと幸いです。

[code]

    public class MainActivity extends NavigationLiveo implements NavigationLiveoListener {
    
        public List<String> mListNameItem;
    
        @Override
        public void onUserInformation() {
            //User information here
            this.mUserName.setText("Rudson Lima");
            this.mUserEmail.setText("rudsonlive@gmail.com");
            this.mUserPhoto.setImageResource(R.drawable.ic_rudsonlive);
            this.mUserBackground.setImageResource(R.drawable.ic_user_background);
        }
    
        @Override
        public void onInt(Bundle savedInstanceState) {
            //Creation of the list items is here
    
            // set listener {required}
            this.setNavigationListener(this);
    
            //First item of the position selected from the list
            this.setDefaultStartPositionNavigation(1);
    
            // name of the list items
            mListNameItem = new ArrayList<>();
            mListNameItem.add(0, getString(R.string.inbox));
            mListNameItem.add(1, getString(R.string.starred));
            mListNameItem.add(2, getString(R.string.sent_mail));
            mListNameItem.add(3, getString(R.string.drafts));
            mListNameItem.add(4, getString(R.string.more_markers)); //This item will be a subHeader
            mListNameItem.add(5, getString(R.string.trash));
            mListNameItem.add(6, getString(R.string.spam));
    
            // icons list items
            List<Integer> mListIconItem = new ArrayList<>();
            mListIconItem.add(0, R.drawable.ic_inbox_black_24dp);
            mListIconItem.add(1, R.drawable.ic_star_black_24dp); //Item no icon set 0
            mListIconItem.add(2, R.drawable.ic_send_black_24dp); //Item no icon set 0
            mListIconItem.add(3, R.drawable.ic_drafts_black_24dp);
            mListIconItem.add(4, 0); //When the item is a subHeader the value of the icon 0
            mListIconItem.add(5, R.drawable.ic_delete_black_24dp);
            mListIconItem.add(6, R.drawable.ic_report_black_24dp);
    
            //{optional} - Among the names there is some subheader, you must indicate it here
            List<Integer> mListHeaderItem = new ArrayList<>();
            mListHeaderItem.add(4);
    
            //{optional} - Among the names there is any item counter, you must indicate it (position) and the value here
            SparseIntArray mSparseCounterItem = new SparseIntArray(); //indicate all items that have a counter
            mSparseCounterItem.put(0, 7);
            mSparseCounterItem.put(1, 123);
            mSparseCounterItem.put(6, 250);
    
            //If not please use the FooterDrawer use the setFooterVisible(boolean visible) method with value false
            this.setFooterInformationDrawer(R.string.settings, R.drawable.ic_settings_black_24dp);
    
            this.setNavigationAdapter(mListNameItem, mListIconItem, mListHeaderItem, mSparseCounterItem);
        }
    
        @Override
        public void onItemClickNavigation(int position, int layoutContainerId) {
    
            FragmentManager mFragmentManager = getSupportFragmentManager();
    
            Fragment mFragment = new FragmentMain().newInstance(mListNameItem.get(position));
    
            if (mFragment != null){
                mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment).commit();
            }
        }
    
        @Override
        public void onPrepareOptionsMenuNavigation(Menu menu, int position, boolean visible) {
    
            //hide the menu when the navigation is opens
            switch (position) {
                case 0:
                    menu.findItem(R.id.menu_add).setVisible(!visible);
                    menu.findItem(R.id.menu_search).setVisible(!visible);
                    break;
    
                case 1:
                    menu.findItem(R.id.menu_add).setVisible(!visible);
                    menu.findItem(R.id.menu_search).setVisible(!visible);
                    break;
            }
        }
    
        @Override
        public void onClickUserPhotoNavigation(View v) {
            //user photo onClick
            Toast.makeText(this, R.string.open_user_profile, Toast.LENGTH_SHORT).show();
        }
    
        @Override
        public void onClickFooterItemNavigation(View v) {
            //footer onClick
            startActivity(new Intent(this, SettingsActivity.class));
        }
    
    
    
    
    public class FragmentMain extends Fragment {
    
        private boolean mSearchCheck;
        private static final String TEXT_FRAGMENT = "TEXT_FRAGMENT";
    
        public FragmentMain newInstance(String text){
            FragmentMain mFragment = new FragmentMain();
            Bundle mBundle = new Bundle();
            mBundle.putString(TEXT_FRAGMENT, text);
            mFragment.setArguments(mBundle);
            return mFragment;
        }
    
        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
            // TODO Auto-generated method stub      
            View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    
            TextView mTxtTitle = (TextView) rootView.findViewById(R.id.txtTitle);
            mTxtTitle.setText(getArguments().getString(TEXT_FRAGMENT));
    
            rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT ));       
            return rootView;        
        }
    
        @Override
        public void onActivityCreated(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onActivityCreated(savedInstanceState);
            setHasOptionsMenu(true);
        }
    
        @Override
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            // TODO Auto-generated method stub
            super.onCreateOptionsMenu(menu, inflater);
            inflater.inflate(R.menu.menu, menu);
    
            //Select search item
            final MenuItem menuItem = menu.findItem(R.id.menu_search);
            menuItem.setVisible(true);
    
            SearchView searchView = (SearchView) menuItem.getActionView();
            searchView.setQueryHint(this.getString(R.string.search));
    
            ((EditText) searchView.findViewById(R.id.search_src_text))
                .setHintTextColor(getResources().getColor(R.color.nliveo_white));
            searchView.setOnQueryTextListener(onQuerySearchView);
    
            menu.findItem(R.id.menu_add).setVisible(true);
    
            mSearchCheck = false;   
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            // TODO Auto-generated method stub
    
            switch (item.getItemId()) {
    
            case R.id.menu_add:
                Toast.makeText(getActivity(), R.string.add, Toast.LENGTH_SHORT).show();
                break;
    
            case R.id.menu_search:
                mSearchCheck = true;
                Toast.makeText(getActivity(), R.string.search, Toast.LENGTH_SHORT).show();
                break;
            }
            return true;
        }   
    
       private SearchView.OnQueryTextListener onQuerySearchView = new SearchView.OnQueryTextListener() {
           @Override
           public boolean onQueryTextSubmit(String s) {
               return false;
           }
    
           @Override
           public boolean onQueryTextChange(String s) {
               if (mSearchCheck){
                   // implement your search here
               }
               return false;
           }
       };
    }
    
[/code]


CC BY-SA 3.0
2015-03-09T15:40:49.560
7672
2015-09-06T14:57:12.523
2015-03-09T18:42:46.383
845
8765
question
android android-fragments
Android Navigation Drawer 遷移先をどう指定するか。


以下で解決出来ました

[code]

    @Override
        public void onItemClickNavigation(int position, int layoutContainerId) {
    
            FragmentManager mFragmentManager = getFragmentManager();
    
            switch (position){
                case 0:
                    Fragment mFragment = new FragmentMain1);
                    mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment).commit();
                    break;
                case 1:
                    Fragment mFragment2 = new FragmentMain2();
                    mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment2).commit();
                    break;
                case 2:
                    Fragment mFragment3 = new FragmentMain3();
                    mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment3).commit();
                    break;
            }
        }
    
[/code]


CC BY-SA 3.0
2015-03-10T07:09:15.427
7712
2015-05-09T11:28:56.740
2015-05-09T11:28:56.740
8000
8765
7672
answer