Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainActivity extends AppCompatActivity {
- protected BottomNavigationView bottomNavigationView;
- protected FrameLayout frameLayout;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- frameLayout = (FrameLayout) findViewById(R.id.content_frame);
- bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation);
- bottomNavigationView.setOnNavigationItemSelectedListener(
- new BottomNavigationView.OnNavigationItemSelectedListener() {
- @Override
- public boolean onNavigationItemSelected(@NonNull MenuItem item) {
- switch (item.getItemId()) {
- case R.id.action_subscribed:
- startActivity(new Intent(getApplicationContext(), SubscribedShowsActivity.class));
- break;
- case R.id.action_search:
- startActivity(new Intent(getApplicationContext(), SearchActivity.class));
- break;
- case R.id.action_upcoming:
- startActivity(new Intent(getApplicationContext(), UpcomingEpisodesActivity.class));;
- break;
- }
- return true;
- }
- });
- }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <FrameLayout
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:id="@+id/content_frame"/>
- <android.support.design.widget.BottomNavigationView
- android:id="@+id/bottom_navigation"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- app:itemBackground="@color/colorPrimary"
- app:itemIconTint="@drawable/nav_item_color_state"
- app:itemTextColor="@drawable/nav_item_color_state"
- app:menu="@menu/bottom_navigation_main" />
- </RelativeLayout>
- public class SubscribedShowsActivity extends MainActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- LayoutInflater inflater = (LayoutInflater) this
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View contentView = inflater.inflate(R.layout.activity_upcoming_episodes, null, false);
- bottomNavigationView.addView(contentView, 0);
- if (savedInstanceState == null) {
- getSupportFragmentManager().beginTransaction()
- .add(R.id.content_frame, new SubscribedShowsFragment())
- .commit();
- }
- }
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- LayoutInflater inflater = (LayoutInflater) this
- .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- View contentView = inflater.inflate(R.layout.activity_search, null, false);
- bottomNavigationView.addView(contentView, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement