11 Implementing Android-specific components and APIs

 

This chapter covers

  • Using DrawerLayoutAndroid to create a side menu
  • Creating a native toolbar with ToolbarAndroid
  • Create paging views using ViewPagerAndroid
  • Create date/time pickers using DatePickerAndroid and TimePickerAndroid
  • Creating toasts using ToastAndroid

In this chapter, we’ll implement the most used Android-specific APIs and components, discuss their props and methods, and create examples that will mimic functionality and logic that will get you up to speed quickly. To see how these work, you’ll create a demo app with a menu, a toolbar, scrollable paging, a date picker, and a time picker. The app will also implement Android toasts. As you implement each of these features, you’ll learn the capabilities of the most commonly used Android-specific APIs and components.

Note

Section 10.1 covered how to target platform-specific code. If you skipped that chapter on iOS-specific components and APIs and don’t already know how to target platform-specific code, you should read that section before continuing.

11.1 Creating a menu using DrawerLayoutAndroid

To get started, you’ll first create a slide-out menu (see figure 11.1). This menu will link to each of the app’s pieces of functionality. It will basically serve as a way to navigate between components. You’ll create this menu using the DrawerLayoutAndroid component.

11.2 Creating a toolbar with ToolbarAndroid

11.3 Implementing scrollable paging with ViewPagerAndroid

11.4 Using the DatePickerAndroid API to show a native date picker

11.5 Creating a time picker with TimePickerAndroid

11.6 Implementing Android toasts using ToastAndroid

Summary