Politeknik Elektronika Negeri Surabaya

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

Android User Interface
Android Using Menus Yuliana Setiowati Rizky Yuniar Hakkun Ahmad Syauqi Ahsan 1Politeknik Elektronika Negeri Surabaya.
User Interface Classes.  Design Principles  Views & Layouts  Event Handling  Menus  Dialogs.
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Android Form Elements. Views Provide common UI functionality Form elements: text area, button, radio button, checkbox, dropdown list, etc. Date and time.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
Introducing the Sudoku Example
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Chapter 2: Simplify! The Android User Interface
MICROSOFT WORD GETTING STARTED WITH WORD. CONTENTS 1.STARTING THE PROGRAMSTARTING THE PROGRAM 2.BASIC TEXT EDITINGBASIC TEXT EDITING 3.SAVING A DOCUMENTSAVING.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,
Basic Android Tutorial USF’s Association for Computing Machinery.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Android Boot Camp for Developers Using Java, 3E
User Interfaces: Part 1 (View Groups and Layouts).
Application Development for mobile Devices
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 2: Simplify! The Android User Interface.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
1 Android Development Lean and mean introduction Based on a presentation by Mihail L. Sichitiu.
Building User Interfaces Basic Applications
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
More App Customizations. Overview  Application/ Activity Customizations: Themes  Menu Customizations  Custom Dialogs  Custom Toasts  Custom Buttons.
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.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 8 Using Document Collaboration, Integration, and Charting Tools Microsoft Word 2013.
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.
Chapter 2: Simplify! The Android User Interface
Creating a Presentation
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Open Handset Alliance.
Chapter 2 Developing a Web Page.
Learning the Basics – Lesson 1
Activities and Intents
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Mobile Application Development BSCS-7 Lecture # 13
Mobile Application Development BSCS-7 Lecture # 11
Chapter II Creating Your First PowerPoint Presentation
Android SDK & App Development
MS PowerPoint 2010 Week 2.
Chapter 1 Editing a Photo
CIS 470 Mobile App Development
Android Layout Basics Topics
CIS 470 Mobile App Development
Building User Interfaces Basic Applications
Using Cascading Style Sheets (CSS)
Android Topics Limited Resources and why we need to consider them.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Mobile Programmming Dr. Mohsin Ali Memon.
User Interface Screen Elements
User Interface Screen Elements
Chapter 8 Using Document Collaboration and Integration Tools
Mobile Programmming Dr. Mohsin Ali Memon.
Android Sensor Programming
Presentation transcript:

Politeknik Elektronika Negeri Surabaya Android Using Menus Politeknik Elektronika Negeri Surabaya Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Outline ContextMenu OptionMenu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Menus is not consuming ‘much’ view space. Android provides two types of menu known as: options menu and context menu. The options menu is triggered by pressing the hardware Menu button on the device, while The context menu is raised by a tap-and-hold on the widget associated to the menu. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example: Using an option menu   Options available in this context Press Menu Button A max of six entries per menu. Excess will be displayed as part of the More option Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example: Using an option menu Press Menu button Available Options in this context Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus (Android 4) Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example : Dealing with SMS (text-messages) by using the built-in Messaging app’s context menu Tap-&-Hold Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Comments on Creating Context Menu Indicate which widget(s) on your activity have context menus. To do this, call registerForContextMenu(theWidget) supplying the View that is the widget needing a context menu. Implement onCreateContextMenu(…) To find out when a context menu choice was chosen, implement onContextItemSelected() on the activity. Politeknik Elektronika Negeri Surabaya

Using Menus - Option Menu (1) Comments on Creating Option Menu Pressing the hardware Menu button on the device. Implement onCreateOptionMenu(…) To find out when a option menu choice was chosen, implement onOptionItemSelected() on the activity. Politeknik Elektronika Negeri Surabaya

Adding Menu

Adding Menu Given that we have received a Menu object via onCreateOptionsMenu(), we add menu choices by calling add(). There are many flavors of this method, which require some combination of the parameters as following: A group identifier (groupId):  This should be NONE unless we are creating a specific grouped set of menu choices for use with setGroupCheckable(). A choice identifier (itemId):  This is for use in identifying this choice in the onOptionsItemSelected() callback when a menu choice is selected. An order identifier (order):  To indicate where this menu choice should be slotted if the menu has Android-supplied choices alongside our own; for now, just use NONE. The text of the menu choice, as a String or a resource ID (title).

Adding Icons Icons can also be added to items that appears in the Icon Menu with setIcon(). For example, if we modify one of the line in the Java code above after put icon into res/drawable/:  menu.add(0, MENU_QUIT, 0, Quit").setIcon(R.drawable.ic_quit);

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using an Option Menu In this application the Option menu offers a way of changing the text size (on both EditText boxes) Click on Menubutton to see size options After choosing option: 50 points Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using an Option Menu Up to six options will be displayed on the Option menu. If there are more than six options pushing the More button will show the rest Click the More button to see additional options Additional choices of the Option menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using a Context Menu Each view could have an associated Context Menu Long-press a textbox to invoke its Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menus Example 1 Example 1: Using Option and Context Menu The app shows two text boxes. Menus are used to change text’s size, color, and style. Politeknik Elektronika Negeri Surabaya

Adding Menu (2) - Menu in XML res/menu/my_menu.xml

Adding Menu (2) - Menu in XML strings.xml

Action Bar

Menu Example - XML Layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Click on the option menu and play with the choices!"/> </LinearLayout>

Menus in XML

menu.xml We must start with a menu root element. Inside a menu element are item elements and group elements. The group element represents a collection of menu items that can be operated upon as a group. When creating our menu resource, we can create a submenu by adding a <menu> element as the child of an <item>. In other words, submenus are specified by adding a menu element as a child of an item element, using this new menu element to describe the contents of the submenu. If we want to detect when an item is chosen, or to reference an item or group from our Java code, be sure to apply an android:id, just as do with View layout XML.

String.xml

Java Code

Java Code

Menu Icons high-density (hdpi) Full Asset: 72 x 72 px  Icon: 48 x 48 px  Square Icon: 44 x 44 px  medium-density (mdpi) Full Asset: 48 x 48 px  Icon: 32 x 32 px  Square Icon: 30 x 30 px  low-density (ldpi)  Full Asset: 36 x 36 px  Icon: 24 x 24 px  Square Icon: 22 x 22

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Example 2: Enhancing Option/Context Menu This extension of the previous example adds icons and links to the Option Menu entries, as well as a sub-menu list tied to one the option menu buttons. Click on SubMenu to see additional options Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Example 2: Enhancing Option/Context Menu This extension of the previous example adds icons and linksto the Option Menu entries, as well as a sub-menu list tied to one the option menu buttons. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Replace the method populateMyFirstMenu with the following code Example 2: Enhancing Option/Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Continuation… Replace the method populateMyFirstMenu with the following code Example 2: Enhancing Option/Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Continuation… Replace the method applyMenuOption with the following code Example 2: Enhancing Option/Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 2 Continuation… Replace the method applyMenuOption with the following code Same as before Example 2: Enhancing Option/Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Comments on Creating Submenus Submenus are displayed as regular Menus Items. When selected they just display more options. To avoid cluttered UIs, submenus are not displayed using three-like structure, instead they appear as a simple floating window presenting a list of items. Android does not support nested submenus. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Comments on Creating Submenus Example: Extend previous example by adding a fifth entry to the existing menu list. The new entry is of the SubMenutype. It should offer three options of its own. Note: add this code to the end of the: onCreateOptionsMenu(…)method. Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Using Option/Context Menu Observe how the selection made from the Menu changes the inter-row spacing of the ListView. Click on Menu to see spacing options After choosing option: 24 Pixels of row separation Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Using Option Click on Menu to see spacing options After choosing option: More a new menu is shown Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Using a Context Menu Tap & Hold any row to bring Context Menu Choices listed in a floating ListView Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 3 Example 3: Creating an Option & Context Menu Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4: Another App Using Menus that include Icons & Text This is a simple application designed around a TableLayout. 1. The first row shows a summary of the data collected from the screen. 2. The second row exposes a RadioGroupand a textBox. 3. The third row shows a list of the calls made to the option and context menus. This Option Menu shows its options using text & icons Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4: Another App Using Menus that include Icons & Text Application’s Layout Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4: Another App Using Menus that include Icons & Text Application’s Layout. Hierarchy View Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text This custom layout (main1.xml) is used to show the ListView rows (shown as red rows –big font ) Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Example 4 Example 4. Menu Using Icons & Text Politeknik Elektronika Negeri Surabaya

Politeknik Elektronika Negeri Surabaya Using Menu Comments on Creating Submenus Example: Extend previous example by adding a fifth entry to the existing menu list. The new entry is of the SubMenutype. It should offer three options of its own. Politeknik Elektronika Negeri Surabaya