T
T
Thymomenos Gata2017-10-23 01:38:09
Android
Thymomenos Gata, 2017-10-23 01:38:09

How to load PreferenceFragment in BottomNavigationView?

To switch between windows using BottomNavigationView, you need to load fragments in FrameLayout.
It looks something like this:

private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
            = new BottomNavigationView.OnNavigationItemSelectedListener() {

        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.navigation_home:
                    loadFragment(MainFragment.newInstance());
                    return true;
                case R.id.navigation_personel:
                    loadFragment(PersonelFragment.newInstance());
                    return true;
                case R.id.navigation_charts:
                    loadFragment(ChartFragment.newInstance());
                    return true;
                case R.id.navigation_tables:
                    loadFragment(TableFragment.newInstance());
                    return true;
                case R.id.action_settings:
                   
                    return true;
            }
            return false;
        }

    };

private void loadFragment(Fragment fragment) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.content, fragment);
        ft.commit();
    }

Is it possible to make a PreferenceFragment appear the same as a simple Fragment in a FrameLayout?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Денис Загаевский, 2017-10-23
@prumin

preference fragment это унылое говно, лучше вообще его не использовать.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question