Android Developer Fundamentals V2 Lesson 4

Slides:



Advertisements
Similar presentations
Cosc 5/4730 Android Navigation: Menus, ActionBar/ToolBar, and Navigation Drawer.
Advertisements

Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Android development the first app. Andoid vs iOS which is better? Short answer: neither Proponents on both sides For an iOS side, see this article on.
1 Mobile Computing Monetizing An App Copyright 2014 by Janson Industries.
Android Layouts. Layouts Define the user interface for an activity Layouts are defined in.xml files – within /res/layout folder – different layout can.
Linear Layout, Screen Support, and Events. Linear Layout Supports 2 orientations: 1.Horizontal 2.Vertical I often get confused with how each orientation.
Resources and RelativeLayouts. Resources Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type.
JQuery UI. Slide 2 Introduction From the jQuery UI Home Page jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
전광판 만들기 UNIT 04 로봇 SW 콘텐츠 교육원 조용수. 학습 목표 Layout XML 이란 ? 기본 XML 속성 Text View 2.
Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Android View Stuff. TextViews Display text Display images???
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Pearson Webcast Series
Recap of Part 1 Terminology Windows FormsAndroidMVP FormActivityView? ControlViewView? ?ServiceModel? Activities Views / ViewGroups Intents Services.
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
Android View Stuff. TextViews Display text Display images???
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
Cosc 5/4730 Support design library. Support Design library Adds (API 9+) back support to a number of 5.0 lollipop widgets and material design pieces –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Resources. Android Resources We’ve already talked about the different types of Android Resources DirectoryResource Type anim/XML files that define tween.
Menus. Menus are a common user interface component in many types of applications. The options menu is the primary collection of menu items for an activity.
Cosc 5/4730 RecyclerView And more..
Lab7 – Appendix.
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Application Development 1 6 May 2018
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Mobile Software Development for Android - I397
Linear Layout, Screen Support, and Events
Android Widgets 1 7 August 2018
Creation of an Android App By Keith Lynn
Politeknik Elektronika Negeri Surabaya
Mobile Application Development BSCS-7 Lecture # 11
ANDROID UI – FRAGMENTS UNIT II.
HNDIT2417 Mobile Application Development
Android SDK & App Development
CIS 470 Mobile App Development
Review 2: Material Design and key widgets.
CS323 Android Model-View-Controller Architecture
Android Programming Lecture 6
Android Layout Basics Topics
CIS 470 Mobile App Development
CA16R405 - Mobile Application Development (Theory)
CMPE419 Mobile Application Development
BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,
Android Developer Fundamentals V2
Activities and Intents
Android: Shapes.
Android Topics Limited Resources and why we need to consider them.
CIS 470 Mobile App Development
Android Developer Fundamentals V2
CIS 470 Mobile App Development
Android Project Structure, App Resources and Event Handling
Adding Components to Activity
Korea Software HRD Center
Building a Simple User Interface
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
CMPE419 Mobile Application Development
CS 240 – Advanced Programming Concepts
Chapter 5 Your Second Activity.
Android: Shapes.
Android Sensor Programming
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Presentation transcript:

Android Developer Fundamentals V2 Lesson 4 Navigation Drawer Lesson 4

Navigation Drawer The navigation drawer is a UI panel that shows your app's main navigation menu. It is hidden when not in use, but appears when the user swipes a finger from the left edge of the screen

Drawer Layout Added to Android v 22.1 So you need to use Android Support Library Declare your root layout with a DrawerLayout. Inside the DrawerLayout, add a layout for the main content for the UI and another view that contains the contents of the navigation drawer.

Drawer Layout <?xml version="1.0" encoding="utf-8"?> <!-- Use DrawerLayout as root container for activity --> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> </android.support.v4.widget.DrawerLayout>

Drawer Layout <?xml version="1.0" encoding="utf-8"?> <!-- Use DrawerLayout as root container for activity --> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- Layout to contain contents of main body --> <LinearLayout android:orientation="horizontal"></LinearLayout> </android.support.v4.widget.DrawerLayout>

Drawer Layout <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> <!-- Layout to contain contents of main body --> <LinearLayout android:orientation="horizontal"></LinearLayout> <!-- Container for contents of drawer --> <android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_gravity="start"/> </android.support.v4.widget.DrawerLayout>

Menu items for nav drawer Create a menu resource with the corresponding file name Add menu Items to the resource file <menu xmlns:android="http://schemas.android.com/apk/res/android"> <group> <item android:id="@+id/nav_camera" android:icon="@drawable/ic_addw" android:title="Add Task" /> android:id="@+id/nav_gallery" android:icon="@drawable/ic_list" android:title="Completed Tasks" /> </group> </menu>

Menu items for nav drawer Configure the menu items listed in the drawer Specify a menu resource with the app:menu attribute <android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="#003366" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" app:menu="@menu/navigation_menu" />

Add a header to the nav drawer You can add a header at the top of the drawer, by specifying a layout with the app:headerLayout attribute <android.support.design.widget.NavigationView android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" android:background="#003366" app:itemIconTint="@android:color/white" app:itemTextColor="@android:color/white" app:menu="@menu/navigation_menu" app:headerLayout="@layout/nav_header"/>

Add a header to the nav drawer <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="192dp" android:background="#5599ff" android:gravity="bottom" android:orientation="vertical" android:padding="16dp" android:theme="@style/ThemeOverlay.AppCompat.Dark"> <TextView android:layout_height="wrap_content" android:gravity="center" android:text="TO DO APP" android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textSize="20sp" android:textStyle="bold" /> </LinearLayout>

Handle navigation click To receive callbacks, implement the OnNavigationItemSelectedListener interface and attach it to your NavigationView by calling setNavigationItemSelectedListener() NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getTitle().toString().startsWith("Add")) getJob(); } mDrawerLayout.closeDrawers(); return true; });

Handle navigation click To receive callbacks, implement the OnNavigationItemSelectedListener interface and attach it to your NavigationView by calling setNavigationItemSelectedListener() NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getTitle().toString().startsWith("Add")) getJob(); } mDrawerLayout.closeDrawers(); return true; });

END