Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package p.alpine12.rootpixelproduct;
- import android.app.FragmentTransaction;
- import android.content.Intent;
- import android.os.Bundle;
- import android.support.annotation.NonNull;
- import android.support.design.widget.BottomNavigationView;
- import android.support.v7.app.AppCompatActivity;
- import android.support.v7.widget.CardView;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- import p.alpine12.rootpixelproduct.fragment.About;
- import p.alpine12.rootpixelproduct.fragment.HomeFragment;
- import p.alpine12.rootpixelproduct.fragment.Produk_Menu;
- public class Home_product extends AppCompatActivity {
- CardView cv_produk;
- private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
- = new BottomNavigationView.OnNavigationItemSelectedListener() {
- @Override
- public boolean onNavigationItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case R.id.navigation_home:
- home_frag();
- return true;
- case R.id.navigation_dashboard:
- product_menu();
- return true;
- case R.id.navigation_notifications:
- about();
- return true;
- }
- return false;
- }
- };
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_home_product);
- home_frag();
- BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
- navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
- }
- void home_frag(){
- HomeFragment homeFragment = new HomeFragment();
- android.support.v4.app.FragmentTransaction fragmentHome =
- getSupportFragmentManager().beginTransaction();
- fragmentHome.replace(R.id.fl_main, homeFragment);
- fragmentHome.commit();
- }
- void product_menu(){
- Produk_Menu produk_menu = new Produk_Menu();
- android.support.v4.app.FragmentTransaction fragmentProduk =
- getSupportFragmentManager().beginTransaction();
- fragmentProduk.replace(R.id.fl_main, produk_menu);
- fragmentProduk.commit();
- }
- void about(){
- About about = new About();
- android.support.v4.app.FragmentTransaction fragmentAbout = getSupportFragmentManager().beginTransaction();
- fragmentAbout.replace(R.id.fl_main, about);
- fragmentAbout.commit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement