Implement a BottomBar without Fragments?

0

Let me explain, I have a BottomBar implemented with 5 Fragments, but it gives me a lot of problems, I can not do practically nothing, because each fragment is extended as Fragment , not as FragmentActivity .

public class MainActivity extends AppCompatActivity {

    BottomBar mBottomBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mBottomBar = BottomBar.attach(this, savedInstanceState);
        mBottomBar.setItemsFromMenu(R.menu.menu_main, new OnMenuTabSelectedListener() {

            @Override
            public void onMenuItemSelected(@IdRes int i) {


                if (i == R.id.one) {

                    First_fragment f1 = new First_fragment();
                    getSupportFragmentManager().beginTransaction().replace(R.id.frame,f1).commit();

                }

                if (i == R.id.two) {

                    Second_fragment f2 = new Second_fragment();
                    getSupportFragmentManager().beginTransaction().replace(R.id.frame, f2).commit();

                }

                if (i == R.id.three) {

                    Three_fragment f3 = new Three_fragment();
                    getSupportFragmentManager().beginTransaction().replace(R.id.frame, f3).commit();

                }

                if (i == R.id.four) {

                    Four_fragment f4 = new Four_fragment();
                    getSupportFragmentManager().beginTransaction().replace(R.id.frame, f4).commit();

                }

                if (i == R.id.five) {

                    Five_fragment f5 = new Five_fragment();
                    getSupportFragmentManager().beginTransaction().replace(R.id.frame, f5).commit();

                }    
            }

        });

        mBottomBar.mapColorForTab(0, "#c92029");
        mBottomBar.mapColorForTab(1, "#c92029");
        mBottomBar.mapColorForTab(2, "#c92029");
        mBottomBar.mapColorForTab(3, "#c92029");
        mBottomBar.mapColorForTab(4, "#c92029");    
    }
}

I put for example First_Fragment , the other 4 are the same:

public class First_fragment extends Fragment {

    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.first_tab,container,false);
        return v;
    }
}

The problem is in extends Fragment , it gives me a lot of problems. My previous questions were of a simple listView and a WebView because in Fragment ALL fails. ** Does anyone know how to change to FragmentActivity in any way or not implement with Fragments ?

    
asked by Rf Mvs 28.10.2016 в 00:09
source

0 answers