Advertisement
alpine12

Untitled

Jul 27th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.73 KB | None | 0 0
  1. package p.alpine12.rootpixelproduct;
  2.  
  3. import android.app.FragmentTransaction;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.support.annotation.NonNull;
  7. import android.support.design.widget.BottomNavigationView;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.support.v7.widget.CardView;
  10. import android.view.Menu;
  11. import android.view.MenuItem;
  12. import android.view.View;
  13. import android.widget.Button;
  14. import android.widget.TextView;
  15.  
  16. import p.alpine12.rootpixelproduct.fragment.About;
  17. import p.alpine12.rootpixelproduct.fragment.HomeFragment;
  18. import p.alpine12.rootpixelproduct.fragment.Produk_Menu;
  19.  
  20. public class Home_product extends AppCompatActivity {
  21.  
  22.     CardView cv_produk;
  23.  
  24.  
  25.     private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
  26.             = new BottomNavigationView.OnNavigationItemSelectedListener() {
  27.  
  28.         @Override
  29.         public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  30.             switch (item.getItemId()) {
  31.                 case R.id.navigation_home:
  32.  
  33.                     home_frag();
  34.  
  35.                     return true;
  36.                 case R.id.navigation_dashboard:
  37.  
  38.                     product_menu();
  39.  
  40.                     return true;
  41.                 case R.id.navigation_notifications:
  42.  
  43.                     about();
  44.  
  45.                     return true;
  46.             }
  47.             return false;
  48.         }
  49.     };
  50.  
  51.     @Override
  52.     protected void onCreate(Bundle savedInstanceState) {
  53.         super.onCreate(savedInstanceState);
  54.         setContentView(R.layout.activity_home_product);
  55.  
  56.         home_frag();
  57.  
  58.         BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
  59.         navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
  60.  
  61.  
  62.     }
  63.  
  64.     void home_frag(){
  65.         HomeFragment homeFragment = new HomeFragment();
  66.         android.support.v4.app.FragmentTransaction fragmentHome =
  67.                 getSupportFragmentManager().beginTransaction();
  68.         fragmentHome.replace(R.id.fl_main, homeFragment);
  69.         fragmentHome.commit();
  70.     }
  71.  
  72.     void product_menu(){
  73.  
  74.  
  75.         Produk_Menu produk_menu = new Produk_Menu();
  76.         android.support.v4.app.FragmentTransaction fragmentProduk =
  77.                 getSupportFragmentManager().beginTransaction();
  78.         fragmentProduk.replace(R.id.fl_main, produk_menu);
  79.         fragmentProduk.commit();
  80.     }
  81.  
  82.     void about(){
  83.         About about = new About();
  84.         android.support.v4.app.FragmentTransaction fragmentAbout = getSupportFragmentManager().beginTransaction();
  85.         fragmentAbout.replace(R.id.fl_main, about);
  86.         fragmentAbout.commit();
  87.  
  88.     }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement