Android Boot Camp for Developers Using Java, 3E

Slides:



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

Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Android User Interface
Chapter 1: Voilà! Meet the Android
Chapter 3: Engage! Android User Input, Variables, and Operations
Chapter 6: Jam! Implementing Audio in Android Apps.
The Web Warrior Guide to Web Design Technologies
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Creating Android user interfaces using layouts 1Android user interfaces using layouts.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Better reference the original webpage :
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
Chapter 3 Navigating a Project Goals & Objectives 1.Get familiar with the navigation of the project. How is everything structured? What settings can you.
Android: versions Note that: Honeycomb (Android v3.0) A tablet-only release Jelly Bean (Android v4.1) Released on July 09, 2012.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Chapter 1: Voilà! Meet the Android
Chapter 10: Move! Creating Animation
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
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.
CS378 - Mobile Computing Intents.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Using Android XML Resources.
© 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.
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.
Engage! Android User Input, Variables,
© 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 Intents. Allow us to use applications and components that are part of Android System – start activities – start services – deliver.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 7: Reveal! Displaying Pictures in a GridView.
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.
Learning With Computers II (Level Orange) ©2012 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly.
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.
First Venture into the Android World Chapter 1 Part 2.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
1 Mobile Computing Handling Different Display Sizes Copyright 2015 by Janson Industries.
© 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.
© 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.
© 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.
© 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.
Positioning Objects with CSS and Tables
© 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.
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.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 10: Move! Creating Animation 1 Android.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 2: Simplify! The Android User Interface
Explore! Icons and Decision-Making Controls
Mobile Applications (Android Programming)
Android Boot Camp for Developers Using Java, 3E
MAD.
Creation of an Android App By Keith Lynn
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Program and Graphical User Interface Design
Presentation transcript:

Android Boot Camp for Developers Using Java, 3E Chapter 2: Simplify! The Android User Interface Android Boot Camp for Developers Using Java, 3rd Ed.

Objectives In this chapter, you learn to: Develop a user interface using the TextView, ImageView, and Button controls Add text in strings.xml using the Translations Editor Create an Android project that includes a Button event Describe Relative and Linear layouts for the user interface Create multiple Android Activities View activities to the Android Manifest file Android Boot Camp for Developers Using Java, 3rd Ed.

Objectives (continued) Add a Java class file Add line numbers to a code window Write code using the onCreate method Display content using the setContentView command Open a second screen using a Button event handler Use an OnClickListener to detect user interaction Launch a second screen using a startActivity method Android Boot Camp for Developers Using Java, 3rd Ed.

Objectives (continued) Correct errors in Java code Run the completed app in the emulator Android Boot Camp for Developers Using Java, 3rd Ed.

Designing an Android App Designing apps is like constructing a building The Big Picture Follow these steps: Create the user interface (XML layout) for every screen Create an Activity (Java class) for every screen Code each Java class with appropriate objects and actions Test the application in the emulator Android Boot Camp for Developers Using Java, 3rd Ed.

Designing an Android App (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the Android User Interface The interface is a window on the screen of any mobile device Addroid apps run on various form factors The layout is designed with XML code Special Android-formatted XML code is extremely compact Android Boot Camp for Developers Using Java, 3rd Ed.

Using the Android User Interface (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the Android User Interface (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor strings.xml is a default file that is part of every Android application and contains commonly used strings for an application Localization is the use of the String table to change text based on the user’s preferred language Every string is composed of a key, also called the id property, which is the name of a control, and a default value, which is the text associated with the control Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Using the String Table in the Translations Editor (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Relative Layouts and Linear Layouts A Relative Layout organizes layout components in relation to each other Provides more flexibility in positioning than Linear layouts Must be changed from the linear default Android Boot Camp for Developers Using Java, 3rd Ed.

Relative Layouts and Linear Layouts (cont’d) A Linear Layout organizes layout components in a vertical column or horizontal row Objects are placed directly below each other Can be switched from vertical to horizontal orientation Linear layout is the default layout Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the Healthy Recipes Opening User Interface The text property uses text from a string resource to display within the control. The textSize property can use various units of measurement, as shown below The preferred unit of measurement is often sp, which stands for scaled-independent pixels Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the Healthy Recipes Opening User Interface (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the Healthy Recipes Opening User Interface (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the Healthy Recipes Opening User Interface (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Designing the Healthy Recipes Opening User Interface (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a File to the Resources Folder Android creates a Drawable resource for any of these images when you save them in the res/drawable folder Android projects have multiple drawable folders that are named after the resolution of the device The five drawable folders are identified with the dpi (dots per inch) densities shown in Table 2-3 Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a File to the Resources Folder (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a File to the Resources Folder (cont’d) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding an ImageView Control An ImageView control displays icons or graphics on the Android screen Android Boot Camp for Developers Using Java, 3rd Ed.

Adding an ImageView Control (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding an ImageView Control (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding an ImageView Control (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Adding a Button Control There are four types of Buttons Button Small Button ToggleButton ImageButton Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities Each screen is considered an activity The point at which the application makes contact with users Constructed using XML layout files and a Java class Planning a program Gather and analyze the program requirements Design the user interface Design the program processing objects Code the program Test the program Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities (continued) Adding a Class File A class describes a group of objects and serves as a blueprint, or template, for creating those objects An object is a specific, concrete instance of a class When you create an object, you instantiate it; meaning you define one particular variation of the object Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Creating Activities (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

The Android Manifest File The Android Manifest file contains: the name of the Java application a listing of each activity permissions needed to access other Android functions (like accessing the Internet) the minimum level of the Android APL Adding an Activity to the Android Manifest When applications have more than one activity, the Manifest must have an intent to navigate among multiple activities Android Boot Camp for Developers Using Java, 3rd Ed.

The Android Manifest File (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Coding the Java Activity A method is a set of Java statements that can be included inside a Java class to perform specific tasks The method body contains a collection of statements that defines what the method does. Coding an onCreate Method Requires corresponding setContentView Java code to display a specific screen Android Boot Camp for Developers Using Java, 3rd Ed.

Coding the Java Activity (continued) Displaying the User Interface Android Boot Camp for Developers Using Java, 3rd Ed.

Coding the Java Activity (continued) Creating a Button Event Handler An event handler is part of a program coded to respond to a specific event Tapping the button is called a click event Java code must contain the following sections Class property to hold a reference to the Button object onClickListener() method to await the button click action onClick() method to respond to the click event Android Boot Camp for Developers Using Java, 3rd Ed.

Coding the Java Activity (continued) When you import the Button type as an Android widget, the button package becomes available throughout the app An import statement makes more Java functions available to your app A stub is a code placeholder module Android Boot Camp for Developers Using Java, 3rd Ed.

Coding a Button Event Handler Android Boot Camp for Developers Using Java, 3rd Ed.

Coding a Button Event Handler (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Coding a Button Event Handler (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Coding a Button Event Handler (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Coding a Button Event Handler (continued) Android Boot Camp for Developers Using Java, 3rd Ed.

Correcting Errors in Code Android Boot Camp for Developers Using Java, 3rd Ed.

Saving and Running the Application Tap or click the Run ‘app’ button on the toolbar to test the application in the emulator A dialog box opens the first time the application is executed requesting which emulator you would like to launch Tap or click Launch emulator and select Nexus 5 API 21x86 or a similar emulator and tap or click the OK button When the emulated Android main screen appears, unlock the emulator Run the application again to send the code to the emulator. The application opens in the emulator window, where you can click the VIEW RECIPE button to view the bruschetta recipe Android Boot Camp for Developers Using Java, 3rd Ed.

Summary Instead of adding text directly to a control’s text property, you add it to the strings.xml file by working with the String table in the Translations Editor Relative layouts arrange components freely on the screen Popular text properties for controls include the text property, which specifies the string resource to use for displaying text in the control, and the textSize property, which specifies the size of the text Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) To display graphics (pictures and icons), use the ImageView control An Activity is when the app makes contact with the user and is a core component of the app Each screen in your app is an Activity Every app has an Android Manifest file containing the name if the app and a list of each activity Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) A method is a set of Java statements that can be included inside a Java class. The onCreate method is where you initialize an Activity. You use the SetContentView command to display the content of a specific screen When the user taps a Button control in an Android app, the code for an event listener, or click event, begins the event associated with the Button control. Event listeners such as the OnClickListener method wait for user interaction before executing the remaining code Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) In an Android app that contains more than one Activity, or screen, you use the startActivity( ) method to create an intent to start another Activity. The intent should contain two parameters: A context and the name of the Activity being opened A context shows which initiating Activity class is making the request Android Boot Camp for Developers Using Java, 3rd Ed.

Summary (continued) When you run an Android application, a dialog box opens if your project contains any errors Look for red error icons and red curly lines, which identify the location of the errors Point to a red curly line to have Java suggest a correction Android Boot Camp for Developers Using Java, 3rd Ed.