Android Fundamentals: Implementing Effective Navigation

This course focuses on navigation with Android. By the end of the course you’ll understand how to implement effective navigation using activities, fragments, alert dialogs, bottom navigation views, navigation drawers, and tabs.
Course info
Rating
(28)
Level
Beginner
Updated
Feb 16, 2018
Duration
2h 42m
Table of contents
Description
Course info
Rating
(28)
Level
Beginner
Updated
Feb 16, 2018
Duration
2h 42m
Description

At the core of every great Android application is an excellent navigation system. In this course, Android Fundamentals: Implementing Effective Navigation, you will learn how to provide a seamless user experience by implementing the various navigation methods in Android. You will take a close look at activities and fragments. You will see how to use alert dialogs. You will also explore bottom navigation views, navigation drawers, and tabs. When you’re finished with this course, you will have a foundational knowledge on navigating Android applications that will help you as you move forward to develop mobile applications.

About the author
About the author

Mitch's passion is teaching. He believes the current education system is outdated and you shouldn't have to spend your life savings to learn about the tech industry.

More from the author
Android Threads: Getting Started
Intermediate
2h 19m
Nov 15, 2018
Firebase on Android: Cloud Firestore
Intermediate
2h 14m
May 16, 2018
More courses by Mitch Tabian
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hello. My name is Mitch Tabian, and welcome to my course, Android Fundamentals: Implementing Effective Navigation. I'm a self-employed Android developer, and I'm here to teach you about implementing effective navigation with Android. Effective navigation is absolutely fundamental to every Android application. The way a user navigates the app will have a huge impact on the overall user experience. As you'll see in the course, back navigation is especially difficult to master. Back navigation refers to the way users travel through the app when pressing the back button or navigating backwards. Some of the major topics we'll cover include navigating with activities and fragments. Having a little bit of both is key to providing a great user experience, and you'll see why. We'll be using a bottom navigation view as the primary method of traversing the app. Personally, I love bottom navigation bars because they provide a very clear method of navigation. A navigation drawer will be used to supplement the app's navigation. Navigation drawers are great for providing a way to centralize or reset a user's location in the app. Tabs are used in almost every app, and it's for good reason. Tabs provide an easy way to swipe through content that's usually static in nature. By the end of the course, you'll have an excellent understanding of the most important concepts when it comes to navigating an app. Effective navigation is absolutely fundamental to providing a great user experience. Before beginning the course, you should be familiar with Android Studio and know how to run applications using the Android emulator or a real device. I hope you'll join me on this journey to learn about navigation with the Implementing Effective Navigation course at Pluralsight.

Getting Started
My name is Mitch Tabian, and welcome to my course, Android Fundamentals: Implementing Effective Navigation. In this course, you'll learn how to build an Android application that uses a number of different navigation methods. If you're familiar with Android, you already know there's many different ways to handle navigation. You can use activities, fragments, dialogs, and various types of views. Then to improve the user experience, Android offers a number of features to enhance navigation. There's tabs, navigation views otherwise known as navigation bars, navigation drawers, floating action buttons, menus, and all the adapter classes that come with them. I don't think I stand alone when I say this can be very confusing, especially if you're new to Android. In this course, we're going to build what I like to call a skeleton of an actual app, so you can see some real examples of when to use activities, when to use fragments, and to enhance the navigation features, like using tabs, navigation views, and navigation drawers. What do I mean by a skeleton? I mean basically the app will have everything a real app will have except real data. To mimic the feel of having real data, we're going to add some dummy data and save it in resource classes and use SharedPreferences. Other than that, the app will essentially be fully functional in that all the navigation and navigation features will be implemented. By the end of the course, my goal is you'll be able to easily implement and determine when to use activities, when to use fragments, when to use alert dialogs, when to use navigation views, when to use tabs, and when to use navigation drawers, and of course how to communicate between all these components because communication is a key part of navigation.

Navigating with Activities
In this module, we'll be focusing on implementing navigation with activities and using alert dialogs. For the duration of the module, we'll be working with the source code files in the directory Module_2/start/TabianDating. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. This module is going to serve as more of an introduction than anything else. Because I want to build the application just as I would if I was building a real app, we're going to start with implementing some minor navigation with activities and then move onto fragments, which occupies a much larger portion of the course. This isn't because activities aren't important. It's just because at this stage in development, there isn't much activity navigation to be done. So in the sections to come, we'll talk more about implement an alert dialog, using an intent to navigate from the login screen to MainActivity, and using some activity animations to make the transition appear smoother.

Implementing a Bottom Navigation View
In this module, we'll be focusing on implementing effective navigation using a NavigationView widget, otherwise known as a navigation bar. For the duration of the module, we'll be working with the source code files in the directory Module_4/start/TabianDating. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. Much like fragments, I think implementing navigation properly using a navigation bar isn't that intuitive. If a developer doesn't have much Android experience, there's a lot of questions that arise. Should you use a navigation bar on the bottom? Should you use it on the top? Should the navigation items open to activities or fragments? Should you be able to swipe through the navigation items? How do you customize a navigation bar, things like setting images and text? Should you save the state of activities or fragments on the navigation bar? The list goes on and on. My aim is to clear up all these questions and hopefully more and give you a general template on how to set up an effective navigation bar.

Implementing a Navigation Drawer
Probably the most common question I get asked about navigation drawers is when to use them. And once again, I have to give this same old answer of it depends. For the duration of the module, we'll be working with the source code files in the directory Module_5/start/TabianDating. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. So when is the best time to use a navigation drawer? I believe in best practices and proper design patterns, but the thing I most believe in that trumps everything else is providing a great user experience. If you're faced with a choice of following a best practice way of doing something or making users happy, I'd go with making users happy every time because remember if user == happy developer = happy. Else if user == angry developer = sad. All jokes aside, coming back to the original question, when do you want to use a navigation drawer? Most of the time I think it should be used to provide a sort of resetting of the navigation or to bring a user back to a central point in your app. This is going to be especially useful to users when navigating a large app with lots of different screens. They can easily get lost in it, and having a simple way to reset without closing the app is going to make them happy. But of course, if you can think of another way to make use of a navigation drawer, one that makes users happier, by all means give it a try. In this course, we're going to be using it as a means to reset back to HomeFragment, access some personalized account settings, and view the app's user agreement. We'll also cover some minor material design concepts that you can use to make your navigation drawer look a little better. They'll be things like setting a header image, setting a header title, adding new items to the navigation drawer, and separating navigation drawer items into groups.

Implementing Tabs
Most mobile applications implement some kind of a TabLayout, and it's for good reason. Tabs provide a convenient way of viewing content by swiping left or swiping right. For the duration of the module, we'll be working with the source code files in the directory Module_7/start/TabianDating. You can download the source code files by navigating to the course on Pluralsight and clicking on the tab labeled Exercise Files. Tabs are one of the few cases when you absolutely need to use fragments. Activities are not an option. Tabs are fragments, but they're a unique type of fragment. To implement tabs effectively, you need to build an adapter class that extents FragmentPagerAdapter. The FragmentPagerAdapter class was designed specifically with tabs in mind and enables tabs to be saved in memory. So as you swipe through them, the contents are not reloaded, and the fragments are not destroyed. Basically, the FragmentPagerAdapter class prevents the fragments from being destroyed and provides a means of organizing them, sort of similar to how we organized our fragments in the custom backstack. If you search the Android documentation for FragmentPagerAdapter, you'll find two classes that are very similar. There's a FragmentPagerAdapter class and a FragmentStatePagerAdapter class. Do not confuse the two. The FragmentPagerAdapter is meant for tabs, and the FragmentStatePagerAdapter is made for when you have many fragments that you want to swipe through. As a rule, the FragmentPagerAdapter should be used if you want to swipe through five fragments or less. The FragmentStatePagerAdapter should be used if you have more. And in that case, you should not use tabs. Setting up tabs is similar to what we've been doing already in the course with a few small differences. We're going to examine the similarities and the differences in the upcoming clips.