Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays,

Slides:



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

Section 6.1 Write Web text Use a mission statement Generate and organize content ideas Section 6.2 Use page dimension guidelines Determine content placement.
Chapter 3: Engage! Android User Input, Variables, and Operations
Chapter 6 Jam! Implementing Audio in Android Apps.
Chapter 6: Jam! Implementing Audio in Android Apps.
App Inventor Barb Ericson July 3, 2013.
 User Interface - Raeha Sandalwala.  Introduction to UI  Layouts  UI Controls  Menus and ‘Toasts’  Notifications  Other interesting UIs ◦ ListView.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
App Inventor Barb Ericson Georgia Tech
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)
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 9: Customize! Navigating with a Master/Detail.
StressChill App Click the StressChill icon (shown to the right) to open the app. If you do not see this on the desktop, you will find it in the pull up.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
CS5103 Software Engineering Lecture 08 Android Development II.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 9: Customize! Navigating with Tabs on a Tablet App.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Chapter 10: Move! Creating Animation
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Simplify! The Android User Interface
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Basic Android Tutorial USF’s Association for Computing Machinery.
Content providers Accessing shared data in a uniform way 1Content providers.
Mobile Computing Lecture#11 Adapters and Dialogs.
© 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.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
Engage! Android User Input, Variables,
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
© 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.
Android Boot Camp for Developers Using Java, 3E
COMP 365 Android Development.  Every android application has a manifest file called AndroidManifest.xml  Found in the Project folder  Contains critical.
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.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
Chapter 5: Windows and Frames
© 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 Two Creating a First Project in Visual Basic.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
© 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.
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 4 Fragments ActionBar Menus. Explore how to build applications that use an ActionBar and Fragments Understand the Fragment lifecycle Learn to.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Chapter 5: Investigate! Lists, Arrays, and Web Browsers.
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
Section 6.1 Section 6.2 Write Web text Use a mission statement
Explore! Icons and Decision-Making Controls
Android Boot Camp for Developers Using Java, 3E
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Using Procedures and Exception Handling
ANDROID LISTS.
Add to the Coffee Ordering App
Presentation transcript:

Android Boot Camp for Developers Using Java, Comprehensive: A Guide to Creating Your First Android Apps Chapter 5: Investigate! Android Lists, Arrays, and Web Browsers 1 Android Boot Camp for Developers Using Java, 2nd Ed.

Objectives In this chapter, you learn to: Create an Android project using a list Develop a user interface that uses ListView Extend the ListActivity class Use an array to create a list Code a setListAdapter to display an array Design a custom ListView layout with XML code Display an image with the ListView control Change the default title bar text 2 Android Boot Camp for Developers Using Java, 2nd Ed.

Objectives (continued) Code a custom setListAdapter for a custom layout Call the onListItemClick method when a list item is selected Write code using the Switch decision structure Call an intent to work with an outside app Open an Android Web browser Launch a Web site through the use of a URI using an Android browser Test an application with multiple decisions 3 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List Lists are one of the most common designs in mobile apps –Scrollable –Selectable –Programmable to bring up the next Activity (screen) 4 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List 5 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Steps to complete the app: 1.Create a list using a ListView control. 2.Define an array to establish the items of the list. 3.Add the images used in the project. 4.Define an XML file to design the custom list with a leading image. 5.Code a switch decision structure to handle the selection of items. 6.Open an Android Web browser to display a specified Uniform Resource Identifier (URI). 7.Create multiple classes and XML layout files to display pictures of attractions. 6 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) –Opening screen contains a vertical list of attractions –List is automatically scrollable if it exceeds the window size –ListView is better than TableLayout View because each row can be selected for further action –Selecting an item opens up a related Web page or an image of the attraction 7 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) 8 Android Boot Camp for Developers Using Java, 2nd Ed. Extending a ListActivity A ListActivity class is needed to display a list of items An ExpandedlistView can be used to provide a two-level list

Creating a List (continued) 9 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Creating an Array –Array variables can store more than one value –Different from other data types that can hold only one value –Each individual item in an array is called an element –Refer to each element using an index in the array 10 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Declaring an Array –Square brackets [ ] are used to define an array –Curley braces { } contain the list of items in the array String[] attraction={"Alcatraz Island", "Ferry Marketplace", "Golden Gate Bridge", "Cable Car Trolley", "Fisherman's Wharf"}; 11 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Using a setListAdapter and Array Adapter –An adapter provides a model for the layout and converts the data into a list –The setListAdapter connects the list items to the images or Web pages they represent –An array adapter supplies the array data to the ListView setListAdapter(new ArrayAdapter (this,android.R.layout.simple_list_item_1, attraction)); 12 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Adding the Images to the Resources Folder –Images must be located in the drawable-hdpi folder –Remember that images may be subject to copyright laws 13 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Changing the Title Bar Text Custom titles can appear in the title bar at the top of the window 14 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Creating a Custom XML Layout for ListView 15 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Creating a Custom XML Layout for ListView (Continued) 16 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Coding a setListAdapter with a Custom XML Layout –Built-in layout is called simple_list_item_1 17 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Using the onListItemClick method –onListItemClick() is called when an item from the list is selected –The item’s position in the list is captured so the app knows which of the items was selected –The position represents the number of the item in the list 18 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Using the onListItemClick method (Continued) 19 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Decision Structure – Switch Statement –If statements are also decision structures –The switch statement is used when there are many list items to be evaluated –Can only evaluate integers or single characters –The keyword case is used to test each item –The keyword break is used to exit the switch decision structure 20 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Decision Structure – Switch Statement (Continued) 21 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Android Intents –Android intents send and receive activities and services including: Opening a Web page Calling a phone number Locating a GPS position on a map Posting notes to a note-taking program Opening your contacts list Posting to a social network 22 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) Launching the Browser from an Android Device –The intent sends the browser a URI (Uniform Resource Identifier) –URI is similar to URL (Uniform Resource Locator) –URI has additional information necessary for gaining access to the resources required for posting the page –The action called ACTION_VIEW (must be in CAPS ) is what actually displays the page in the browser –ACTION_VIEW is the most common action performed on data 23 Android Boot Camp for Developers Using Java, 2nd Ed.

Creating a List (continued) 24 Android Boot Camp for Developers Using Java, 2nd Ed.

Designing XML Layout Files –XML layout files must be designed to display an ImageView control with an image source file 25 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Designing XML Layout Files (Continued) 26 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Designing XML Layout Files (Continued) 27 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Adding Multiple Class Files –A new class is needed to display each image –Classes must be referenced in the Android Manifest File Code for Wharf.java class (Bridge and trolley already created) 28 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Adding Multiple Class Files (Continued) 29 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Opening the Class Files –startActivity opens the next Activity which launches the appropriate XML layout Running and testing the Application –Be sure to test every option –Should handle all clicks 30 Android Boot Camp for Developers Using Java, 2nd Ed. Creating a List (continued)

Summary The Java View class creates a list and makes it scrollable; use a ListView control to select each row for further action Extend the ListActivity class in Main.java to display a ListView control Declare list items in an array variable The index provides access to each element in the list (the list begins with 0) To declare an array, specify the data type followed by the values 31 Android Boot Camp for Developers Using Java, 2nd Ed.

Summary (continued) Use an adapter to display the values in the array A ListView control is a container for the list items and the adapter binds the elements of the array to the ListView layout statements if the condition is false Drag controls from the palette to the emulator for a simple design Add code to the main.xml file to get a custom layout 32 Android Boot Camp for Developers Using Java, 2nd Ed.

Summary (continued) App names are displayed in the app title bar – can be customized setListAdapter has 3 parameters: –this class –The layout used to display the list –The array containing the list values Code the onListItemClick method to respond to the event of the user’s selection Use the switch decision structure with a list or menu 33 Android Boot Camp for Developers Using Java, 2nd Ed.

Summary (continued) Android intents send and receive activities and services Test every possible combination of clicks, including incorrect user entries before publishing the app 34 Android Boot Camp for Developers Using Java, 2nd Ed.