Android Programming

Android NavigationView  ListView tutorial.

Android NavigationView - Fragments With ListView

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

What we do :

  • Use navigationview.
  • The navigationview shall get placed inside a drawer layout.
  • The navigation menu shall be populated with menu items.
  • These shall get inflated from XML layouts.
  • When we click a navigationview item,we shall switch through fragments.
  • We do this by performing fragment transactions,hence replacing our content view with our new fragment.
  • The fragments shall have listview.
  • If you click a single listview item we show a toast message.

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 listview.
  • Navigation drawer.
  • listview 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.
  • 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
  6. Downloader class.
  7. DataParser class.
  8. CustomAdapter 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 Code Here.