Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong.

Slides:



Advertisements
Similar presentations
Android UserInterfaces Nasrullah Niazi. overView All user interface elements in an Android app are built using View and ViewGroup objects. A View is an.
Advertisements

All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
Cosc 5/4730 Android Navigation: Menus, ActionBar/ToolBar, and Navigation Drawer.
Layout and Control in UI The user interface (UI) is the graphical interface user can see and interact with your app comprising UI controls like textbox,
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Development (Basics)
Android: Layouts David Meredith
GAO YUAN We are here for:  We know iPhone from iOS Human Interface Guidelines  The guidelines and principles that help you.
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.
ANDROID UI – FRAGMENTS. Fragment  An activity is a container for views  When you have a larger screen device than a phone –like a tablet it can look.
Chapter 2: Simplify! The Android User Interface
ANDROID – INTERFACE AND LAYOUT L. Grewe. Interfaces: Two Alternatives Code or XML  You have two ways you can create the interface(s) of your Application.
Cosc 5/4730 Introduction: Threads, Android Activities, and MVC.
@2011 Mihail L. Sichitiu1 Android Introduction GUI Menu Many thanks to Jun Bum Lim for his help with this tutorial.
Frank Xu Gannon University.  Linear Layout  Relative Layout  Table Layout.
Mobile Computing Lecture#11 Adapters and Dialogs.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
User Interfaces: Part 1 (View Groups and Layouts).
Chapter 7: Reveal! Displaying Pictures in a Gallery.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Networking: Part 1 (Web Content). Networking with Android Android provides A full-featured web browser based on Chromium, the open source browser engine.
Cosc 4730 Android Fragments. Fragments You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own.
Copyright© Jeffrey Jongko, Ateneo de Manila University Custom ListAdapters.
Video Games list lab 6  At the end of this lab you will be expected to know:  What Views, View Groups, Layouts, and Widgets are and how they relate to.
Mobile Programming Lecture 7 Dialogs, Menus, and SharedPreferences.
ListView and ExpandableListView
Pearson Webcast Series
Android Application Lifecycle and Menus
Web Site Development - Process of planning and creating a website.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
Building User Interfaces Basic Applications
TCS Internal Maps. 2 TCS Internal Objective Objective :  MAPS o Integration of Maps.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
CHAPTER 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Http :// developer. android. com / guide / topics / fundamentals. html.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
School of Engineering and Information and Communication Technology KIT305/KIT607 Mobile Application Development Android OS –Permissions (cont.), Fragments,
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
UI Redux, Navigation Patterns, Tabbed Views, Pagers, Drawers
Fragments and Menus Chapter 4 1. Objectives Learn three different types of menus: options, context, and popup Learn to configure the ActionBar and Toolbar.
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.
Lab7 – Appendix.
Introduction to android
Android Programming - Features
UNIT 11 로봇 전화번호부 3/4 로봇 SW 콘텐츠 교육원 조용수.
CS240: Advanced Programming Concepts
GUI Programming Fundamentals
Android – Event Handling
Mobile Application Development BSCS-7 Lecture # 8
Android Widgets 1 7 August 2018
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Mobile Application Development BSCS-7 Lecture # 11
CIS 470 Mobile App Development
Review 2: Material Design and key widgets.
Android Programming Lecture 6
CIS 470 Mobile App Development
Android Topics Custom ArrayAdapters
Android Developer Fundamentals V2 Lesson 4
CIS 470 Mobile App Development
Mobile Programming Gestures in Android.
Activities and Fragments
CS 240 – Advanced Programming Concepts
Android Sensor Programming
Android Sensor Programming
Presentation transcript:

Create Navigation Drawer Team 2 Zhong Wang Jiaming Dong Philip Wu Lingduo Kong

Introduction -The navigation drawer is a panel that displays the app’s main navigation options on the left (or optionally from right) edge of the screen. -It is hidden most of the time, but is revealed when the user swipes a finger from the left (or optionally from right) edge of the screen - or, while at the top level of the app, the user touches the app icon in the action bar.

- implement a navigation drawer using the DrawerLayout APIs available in the Support Library. DrawerLayoutSupport Library Create a Drawer Layout - To add a navigation drawer, declare your user interface with a DrawerLayout object as the root view of your layout.DrawerLayout - Inside the DrawerLayout, add one view that contains the main content for the screen (your primary layout when the drawer is hidden) and another view that contains the contents of the navigation drawer.DrawerLayout

Sample DrawerLayout

Sample DrawerLayout - the above layout uses a DrawerLayout with two child views:DrawerLayout Change activity_main.xml to navigation drawer layout. -a FrameLayout to contain the main content (populated by a Fragment at runtime),FrameLayoutFragment -and a ListView (ExandableListView) for the navigation drawer.ListView

This layout demonstrates some important layout characteristics: The main content view (the FrameLayout above) must be the first child in the DrawerLayout because the XML order implies z-ordering and the drawer must be on top of the content.FrameLayoutDrawerLayout The main content view is set to match the parent view's width and height, because it represents the entire UI when the navigation drawer is hidden. The drawer view (the ListView) must specify its horizontal gravity with the android:layout_gravity attribute. To support right-to-left (RTL) languages, specify the value with "start" instead of "left" (so the drawer appears on the right when the layout is RTL).ListView The drawer view specifies its width in dp units and the height matches the parent view. The drawer width should be no more than 320dp so the user can always see a portion of the main content.

Prepare MainActivity properties DrawerLayout mDrawerlayout; ActionBarDrawerToggle mDrawerToggle; ImageButton imgRightMenu; ExpandableListAdapter mDrawerList_Right; ExpandableListView expendListView; List listDataHeader; HashMap > listDataChild; Initialize the Drawer List In your activity, one of the first things to do is initialize the navigation drawer's list of items. How you do so depends on the content of your app, but a navigation drawer often consists of a ListView, so the list should be populated by an Adapter (such as ArrayAdapter or SimpleCursorAdapter).ListViewAdapterArrayAdapterSimpleCursorAdapter For example, you can initialize the navigation list with a string array:string array

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //===============Initialization of Variables=========================// mDrawerlayout = (DrawerLayout) findViewById(R.id.drawer_layout); imgRightMenu = (ImageButton) findViewById(R.id.imgRightMenu); mDrawerlayout.setDrawerListener(mDrawerToggle); expendListView = (ExpandableListView) findViewById(R.id.drawer_list_right); // Set the list's click listener expendListView.setOnGroupClickListener(myListGroupClicked); prepareListData(); mDrawerList_Right = new ExpandableListAdapter(this, listDataHeader, listDataChild); // Set the adapter for the list view expendListView.setAdapter(mDrawerList_Right);

//============== Define a Custom Header for Navigation drawer=================// LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.navigation_header, null); imgRightMenu = (ImageButton) v.findViewById(R.id.imgRightMenu); getSupportActionBar().setHomeButtonEnabled(true); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#1281A9"))); getSupportActionBar().setIcon( new ColorDrawable(getResources().getColor(android.R.color.transparent))); getSupportActionBar().setCustomView(v);

imgRightMenu.setOnClickListener(new OnClickListener() public void onClick(View v) { // TODO Auto-generated method stub if (mDrawerlayout.isDrawerOpen(expendListView)) { mDrawerlayout.closeDrawer(expendListView); } else { mDrawerlayout.openDrawer(expendListView); } } });

private ExpandableListView.OnGroupClickListener myListGroupClicked = new ExpandableListView.OnGroupClickListener() { public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if(groupPosition == 3) { Intent preference = new Intent(MainActivity.this, PreferencesActivity.class); startActivity(preference); } return false; } };

Create menu and submenus listDataHeader = new ArrayList (); listDataChild = new HashMap >(); // Adding child data listDataHeader.add("Top 250"); … // Adding child data List top250 = new ArrayList (); top250.add("The Shawshank Redemption"); top250.add("The Godfather"); listDataChild.put(listDataHeader.get(0), top250); // Header, Child data listDataChild.put(listDataHeader.get(1), nowShowing);

ExpandableListAdapter An adapter that links a ExpandableListView with the underlying data.ExpandableListView The implementation of this interface will provide access to the data of the children (categorized by groups), and also instantiate Views for children and groups.View

public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

protected void onCreate(Bundle savedInstanceState) public boolean onCreateOptionsMenu(Menu menu) public boolean onOptionsItemSelected(MenuItem item) {