Favorite Twitter® Searches App Android How to Program ©1992-2013 by Pearson Education, Inc. All Rights Reserved.

Slides:



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

Microsoft Excel 2003 Illustrated Complete Excel Files and Incorporating Web Information Sharing.
Unlocking Android Chapter 4.  Understanding activities and views  Exploring the Activity lifecycle  Working with resources  Defining the AndroidManifest.xml.
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
ANDROID PROGRAMMING MODULE 1 – GETTING STARTED
Android Development (Basics)
Android Application Development 2013 PClassic Chris Murphy 1.
CST JavaScript Validating Form Data with JavaScript.
Better reference the original webpage :
Introducing the Sudoku Example
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Chapter 2: Simplify! The Android User Interface
Android How to Program Presented by Thomas Bucag, Rob Goodfellowe, Samantha Tomeï © by Pearson Education, Inc. All Rights Reserved.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Understanding Hello Android 1 CS300. Activity  Similar to a form  Base class for the visual, interactive components of your application  Android API.
Doodlz App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
DUE Hello World on the Android Platform.
CS378 - Mobile Computing Intents.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
JavaScript: Functions © by Pearson Education, Inc. All Rights Reserved.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
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.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
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, 3E
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.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Topics Introduction Scene Graphs
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
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.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Creating multiple views Introduction to intents Passing data to.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Android Intents Nasrullah. Using the application context You use the application context to access settings and resources shared across multiple activity.
CS378 - Mobile Computing User Interface Basics. User Interface Elements View – Control – ViewGroup Layout Widget (Compound Control) Many pre built Views.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Building User Interfaces Basic Applications
Chapter 29. Copyright 2003, Paradigm Publishing Inc. CHAPTER 29 BACKNEXTEND 29-2 LINKS TO OBJECTIVES Attach an XML Schema Attach an XML Schema Load XML.
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
The Ingredients of Android Applications. A simple application in a process In a classical programming environment, the OS would load the program code.
INTRODUCTION TO ANDROID. Slide 2 Introduction I take a top-down approach to describing an application’s anatomy.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
Working with Multiple Activities. Slide 2 Introduction Working with multiple activities Putting together the AndroidManifest.xml file Creating multiple.
Editing a Twitter search. Viewing search results in a browser.
Chapter 2: Simplify! The Android User Interface
Java FX: Scene Builder.
Mobile Applications (Android Programming)
Chapter Topics 15.1 Graphical User Interfaces
MAD.
Activities and Intents
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Anatomy of an Android Application
Cannon Game App Android How to Program
Favorite Twitter Searches App
Building User Interfaces Basic Applications
Favorite Twitter Searches App
Chapter 15: GUI Applications & Event-Driven Programming
Presentation transcript:

Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.

A ScrollView can contain other views (like a layout) and lets user scroll through content too large to display on the screen. Technologies Overview

SharedPreferences ▫ Used to manipulate a file of key/value pairs, which stores tags and Twitter search queries ▫ Going to read in the saved searches in refreshButtons method called from Activity’s OnCreate method  Acceptable because file is small Intents ▫ Typically used to launch activities ▫ Indicate an action to be performed and the data on which it is to be performed ▫ When button is touched, create a URL containing Twitter query, load into browser by creating new Intent, then pass Intent to startActivity method to launch browser. © by Pearson Education, Inc. All Rights Reserved.

Technologies Overview LayoutInflater ▫ Programmatically creates GUI components  In out app, each new search, adds another row. AlertDialog ▫ Used to display a message to the user  In case one of the EditText’s is empty or to confirm Clear ▫ While the dialog is displayed, user cannot interact with app (modal dialog) AndroidManifest.xml ▫ Created for you, when you create the app ▫ Add a new setting to the manifest to prevent the soft keyboard from displaying when the app first loads. © by Pearson Education, Inc. All Rights Reserved.

Building the App’s GUI and Resource Files Create project Create Resource Files ▫ colors.xml, dimen.xml, strings.xml Delete and Recreate main.xml Create GUI: Add TableLayout and Components Review Key features in main.xml Create another layout XML file ▫ Will define a TableRow that will be programmatically inflated to create each search Button and corresponding EditButton © by Pearson Education, Inc. All Rights Reserved.

Creating Resource Files Right click project name Select New > Other Select Android XML file from Android node in the New dialog Enter name of the xml file Under “What type of resource would you like to create?”, select Values Click Finish © by Pearson Education, Inc. All Rights Reserved.

User’s search queries are appended to this URL, before ahe twitter search is displayed.

© by Pearson Education, Inc. All Rights Reserved. From R.color class Can find list online Stretch horizontally to fill layout’s width Remember some of the attributes must be specified directly in the XML. Enables you to configure options for the current input method, here keyboard will have a a next button. Will change focus to next component that can accept input – tagEditText.

© by Pearson Education, Inc. All Rights Reserved. Button for saving a search. Here keyboard will have a a done button - will hide the soft keyboard.

© by Pearson Education, Inc. All Rights Reserved.

Search buttons will be displayed programatically in ScrollView

© by Pearson Education, Inc. All Rights Reserved.

Create another layout XML file ▫ Right click layout folder and select New > Other ▫ In Android node, select Android XML file and click Next ▫ Enter new_tag_view.xml ▫ Under “What type of resource…?” select Layout radio button. ▫ Select the root element for the new layout – Choose TableRow. ▫ Click Finish. ▫ In Graphical Layout, select Android version and Device Configuration ▫ Add two buttons to the layout and configure them.  Text property will be configured programmatically. © by Pearson Education, Inc. All Rights Reserved.

new_tag_view.xml © by Pearson Education, Inc. All Rights Reserved. So parent’s color shows through.

Building the App Package and import statements Write main (and only) Activity class for app Override OnCreate Write programmer defined refreshButton, makeTag, makeTagGUI, clearButtons methods Write 4 Inner Classes to implement OnClickListener for ▫ saveButton ▫ clearTagsButton ▫ newTagsButton ▫ editButton Edit AndroidManifest.xml file © by Pearson Education, Inc. All Rights Reserved.

The Java Code © by Pearson Education, Inc. All Rights Reserved. Sort tags. Access Android services. Used to manipulate key/value Pairs in files associated with app. Convert an Internet URL into proper format. Deals with soft keyboard. Dynamically inflate layout

© by Pearson Education, Inc. All Rights Reserved. Declare instance variables.

© by Pearson Education, Inc. All Rights Reserved. Read tag/query pairs from “searches” file. MODE_PRIVATE specifies accessibility to file: this file is ONLY accessible to this app.

© by Pearson Education, Inc. All Rights Reserved. Get more references. Call programmer defined method.

© by Pearson Education, Inc. All Rights Reserved. Call programmer defined method.

© by Pearson Education, Inc. All Rights Reserved. Or modifies an existing query

© by Pearson Education, Inc. All Rights Reserved. Android provides a service that enable you to inflate a layout. To obtain this service, you obtain a reference to it.

© by Pearson Education, Inc. All Rights Reserved.

Argument to the Builder constructor is the context in which the dialog sill be displayed. Must be fully qualified, because we are calling it from within an anonymous inner class.

© by Pearson Education, Inc. All Rights Reserved. to confirm all stored searches to be removed Define positive button AND its event handler

© by Pearson Education, Inc. All Rights Reserved. Dialog is cancellable; user can touch back button to dismiss dialog

© by Pearson Education, Inc. All Rights Reserved. Event handler, registered for Each newTagButton as it is created Gets text of the button clicked Gets corresponding search query arg1 – constant to display data arg2 – uniform resource id to data on which we want to perform the action

© by Pearson Education, Inc. All Rights Reserved.

Android Manifest File When you create a project for an Android app in Eclipse, the ADT Plugin creates and configures AndroidManifest.xml file ▫ Describes information about the app ▫ The manifest element is the root element  package attribute  versionCode and versionName attributes  icon attribute  label attribute (name of the app)  uses-sdk specifies target SDK and min SDK version  WITHIN application element is the activity element © by Pearson Education, Inc. All Rights Reserved.

Activity element Activity elements are contained within application element If the app has more than one activity, each will have its own activity element Name attribute – specifies Activity’s class name, if preceded by a dot (.), class name is auto appended to a package name specified in manifest element windowSoftInputMode here is specified NOT to show the soft keyboard when activity is launched ▫ Can edit xml directly or open the manifest editor by double-clicking on the AndroidManifest.xml file © by Pearson Education, Inc. All Rights Reserved.

Activity element cont. Within activity element is the intent-filter element ▫ Specifies types of intents the Activity can respond to ▫ The intent-filter element must contain one or more action elements This contains just one action MAIN and its category is LAUNCHER ▫ This indicates that this activity should be listed in the application launcher with other apps on the device © by Pearson Education, Inc. All Rights Reserved.

Wrap-up Introduced ScrollView (ViewGroup) and Button Learned how to create resource files using New Android XML File dialog ▫ color.xml, dimen.xml and new_tag_view.xml Learned how to create GUI components dynamically by inflatin an XML layout Learned how to store key/value pairs in SharedPreferences and manipulate them Learned how to programmatically hide the soft keyboard © by Pearson Education, Inc. All Rights Reserved.

Wrap-up Learned how to load a URI into a device’s web browser by creating a new Intent and passing it to Context’s startActivity method Learned how to use AlertDialog.Builder to configure and create AlertDialogs for displaying message to the user Learned how to use Arrays to sort and search Learned a bit about the AndroidManifest file and how to configure it © by Pearson Education, Inc. All Rights Reserved.