SHARE
TWEET

MainActivity

a guest Jul 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.catalogmovie;
  2.  
  3. import android.os.Bundle;
  4. import android.support.design.widget.BottomNavigationView;
  5. import android.support.v4.app.Fragment;
  6. import android.support.v7.app.AppCompatActivity;
  7. import android.support.annotation.NonNull;
  8. import android.view.MenuItem;
  9. import android.widget.FrameLayout;
  10.  
  11. import com.example.catalogmovie.Fragment.MoviesFragment;
  12. import com.example.catalogmovie.Fragment.TvFragment;
  13.  
  14.  
  15. public class MainActivity extends AppCompatActivity {
  16.  
  17.     private FrameLayout flMovies;
  18.  
  19.     private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
  20.             = new BottomNavigationView.OnNavigationItemSelectedListener() {
  21.  
  22.         @Override
  23.         public boolean onNavigationItemSelected(@NonNull MenuItem item) {
  24.  
  25.             Fragment fragment;
  26.  
  27.             switch (item.getItemId()) {
  28.                 case R.id.navigation_home:
  29.                     fragment = new MoviesFragment();
  30.                     getSupportFragmentManager().beginTransaction()
  31.                             .replace(R.id.container_layout, fragment, fragment.getClass().getSimpleName())
  32.                             .commit();
  33.                     return true;
  34.  
  35.                 case R.id.navigation_dashboard:
  36.                     fragment = new TvFragment();
  37.                     getSupportFragmentManager().beginTransaction()
  38.                             .replace(R.id.container_layout, fragment, fragment.getClass().getSimpleName())
  39.                             .commit();
  40.                     return true;
  41.             }
  42.             return false;
  43.         }
  44.     };
  45.  
  46.     @Override
  47.     protected void onCreate(Bundle savedInstanceState) {
  48.         super.onCreate(savedInstanceState);
  49.         setContentView(R.layout.activity_main);
  50.         BottomNavigationView navView = findViewById(R.id.navigation);
  51.         navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
  52.  
  53.         flMovies = findViewById(R.id.container_layout);
  54.  
  55.  
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top