Sunday , November 28 2021

Bottom Navigation Android Example using Fragments – Android Coding by DMTechnolab

The package The trap.Simplified coding.bottomnavigationexample;

Import Android..Bundle;

Import Android.Support.Annotation.No no;

Import Android.Support.The design.Widget.Bottom view;

Import Android.Support.v4.App.Cut into pieces;

Import Android.Support.v7.App.AppCompatActivity;

Import Android.Opinion.menu item;

// Apply the interface OnNavigationItemSelectedListener to your activity class

public class Main activity Is spread AppCompatActivity come into force Bottom view.OnNavigationItemSelectedListener {{

@ Override

Protected Zero Go ahead()Bundle saveInstanceState) {{

Super.Go ahead()saveInstanceState);

setContentView()R.Layout.activity_main);

// default piece loading

burden()New Homograph()));

// Getting the navigation view below and engaging the listener

Bottom view Navigation = findViewById()R.Id.Navigation);

Navigation.setOnNavigationItemSelectedListener()this);

}

@ Override

public Boolean onNavigationItemSelected()@Nonal menu item item) {{

Cut into pieces The piece = Invalid;

to switch ()item.getItemId())) {{

matter R.Id.Navigation_home:

The piece = New Homograph());

break;

matter R.Id.Navigation_dashboard:

The piece = New Dashboard fragment());

break;

matter R.Id.Navigation:

The piece = New Notifications());

break;

matter R.Id.Navigation_profile:

The piece = New Profile fragment());

break;

}

The return burden()The piece);

}

Private Boolean burden()Denial The piece) {{

// switching piece

If ()The piece ! = Invalid) {{

getSupportFragmentManager())

.Beginning())

.To change()R.Id.Slicer, The piece)

.Committed());

The return True;

}

The return false;

}

}


Source link

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *