Android Programming

Android NavigationView  GridView tutorial.

Android NavigationView - Fragments With Gridview

Navigationview is one of the standard navigation menus in android.Its normally placed inside a drawer layout.Today we want to switch through navigationview menu items,thereby showing fragments.Now in this case our fragments are going to consist of GridViews.Each gridview of course has unique data.  

What we do :

  • We are covering navigationview with gridviews.
  • The naviagtionview shall exist in a drawer layout.
  • It shall consist of navigationview menu items.
  • These we add through xml.
  • When we click a navigationview item,we swicth through fragments.
  • We do this by performing a fragment transaction,replacing our layouts with fragment layouts.
  • We shall be creating fragment classes.
  • These shall derive from support library fragment base class.
  • Our fragments shall gridviews.
  • Each gridview is bound to unique data.

Common Questions we answer :

  • Using an navigation view.
  • Drawer layout and navigation view tutorial.
  • Navigation view and fragments example.
  • NavigationView items event listener.
  • NavigationViewItemselectedlistener.
  • Fragments transactions.
  • Replace fragments.
  • Fragments with GridView .
  • Navigation drawer.
  • GridView onitemclick.

What You'll do :

  • Create a project in android studio.
  • Give it a name and choose minimum and target SDKs.
  • Choose navigation drawer template.
  • Add a dependency statement for a Picasso library we'll use.
  • Run your project.
  • I tested mine in Genymotion emulator.

Overview :

  1. MainActivity class
  2. InterPlanetary Fragment class.
  3. InterStellarFragment class.
  4. InterGalactic Fragment class.
  5. InterUniverse Fragment class
  1. ActivityMain.xml
  2. ContentMain.xml
  3. app_bar_main.xml
  4. interplanetary.xml.
  5. interstellar.xml
  6. intergalactic.xml
  7. interuniverse.xml
Source Code Download Download Full Source code Here.