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.

Slides:



Advertisements
Similar presentations
Android Application Development Tutorial. Topics Lecture 6 Overview Programming Tutorial 3: Sending/Receiving SMS Messages.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
Programming with Android: Widgets and Events Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna.
Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Basic Functionality in Android. Functionality in Android Events in Java – mouse related mouse clicked button down or up mouse entered – many others key.
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
More Java: Encapsulation, Getters, Setters, Anonymous Class 1 CS300.
Button click handlers Maarten Pennings. Introduction An activity has one or more views – view is also known as widget or control – examples include Button,
@2010 Mihail L. Sichitiu1 Android Introduction Hello Views Part 2.
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.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
Android Development (Basics)
App Development on Android. Contents  First Milestone  Second Milestone  Third Milestone  Last Milestone 
Introduction to Android Development CS 5115 Fall 2013 September 23.
Chapter 8: String Manipulation
Introducing the Sudoku Example
 Understanding an activity  Starting an activity  Passing information between activities  Understanding intents  Understanding the activity lifecycle.
KJOlinski.com - RapidHMI INTRODUCING RapidHMI AND PLCExplorer.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Chapter 2: Simplify! The Android User Interface
Prerequisites Android Studio – io.html io.html Java.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
Chapter 5 Creating User Interfaces GOALS and OBJECTIVES Begin our application by creating our user interface. More than one way to create a user interface.
DUE Hello World on the Android Platform.
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Chapter 2 The Android User Interface. Objectives  In this chapter, you learn to:  Develop a user interface using the TextView, ImageView, and Button.
1 Building the CarryDrop Simulation in JBuilderX By Deddy Koesrindartoto 08/16/2004.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Programming Mobile Applications with Android September, Albacete, Spain Jesus Martínez-Gómez.
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.
© 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.
Field Trip #32 Digital Alarm Clock By Keith Lynn.
User Interface Android Club Agenda Button OnClickListener OnLongClickListener ToggleButton Checkbox RatingBar AutoCompleteTextView.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Handling View Events. Open the *MainActivity.java* which is the Activity that hosts the layout in "activity_main.xml". The setContentView method inside.
Activities  For this lab we will be creating a “Video Games List" application.  It is a simple app that allows a user to view and edit a list of video.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
Android - SQLite Database 12/10/2015. Introduction SQLite is a opensource SQL database that stores data to a text file on a device. Android comes in with.
Designing user interfaces using: Simple views 1. Views Basic views – TextView – EditText – Button – ImageButton – CheckBox – ToggleButton – RadioButton.
Adapters 1 CS440. Adapters (again!)  Adapters are bridging classes, that bind data to user-interface Views. The adapter is responsible for creating the.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
Lec 06 Agenda 1/ the 8 rules of Java 2/ Casting primitives 3/ Swing and Threading 4/ Java Event Model. Event api and support for Swing 5/ Swing labs, live.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
User Interface Layout Interaction. EventsEvent Handlers/Listeners Interacting with a user.
Events. Slide 2©SoftMoore Consulting Events Events are generated when a user interacts with the view objects of an application. Examples –button clicked–
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Mobile Programming Lecture 4 Resources, Selection, Activities, Intents.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
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 –
Menu & Clipboard Menu Cut / Copy / Paste. Menus Created in the Menu Editor Can contain menu titles, menu items, separator bars, submenu titles, and submenu.
ANDROID DIALOGS. Slide 2 Dialogs (Introduction) The Dialog class is the base class for all dialogs A dialog is a small window that prompts the user to.
CompSci 230 S Programming Techniques
Lab7 – Advanced.
several communicating screens
Android Programming Lecture 3.
Android – Event Handling
Android Database using SQLite
Mobile Application Development Chapter 5 [Persistent Data in Android]
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
ITEC535 – Mobile Programming
Windows Desktop Applications
Android Introduction Hello Views Part 2.
Android Topics Custom ArrayAdapters Creating an Event Listener
Android Developer Fundamentals V2
Presentation transcript:

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 each other.  How to declare layouts dynamically at runtime.  How to reference resources in code and from other resource layout files.  How to use Events and Event Listeners. CS440 1

Part 3: Game List  Modify the view:  Goto main.xml  Delete the current view  Add a text editor with ID GameText, a button with ID btnAdd and a listview with ID GameListView  Add these widgets as properties in the GameListActivity class  Find the objects: edit text, button and list view using findViewById (look at the android API for more information)  Set key listener for the edit text and click listener for the button CS440 2

Part 3: Game List  Create GameList property as an ArrayList of Strings  Create an Array Adapter aa property(see android API)  Create addGame(String GameTitle) method in the GameListActivity class  Add the game title to the list  Notify the adapter that the data set has changed (see android API)  Clear the text for the Edit Text widget CS440 3

Part 4: Add event listeners  The GameListActivity class needs to implement two listeners:  OnClickListener,  OnKeyListener CS440 4

Part 4: Add event listeners  Setup the onClickListener for the "Add Game" Button.  When the user hits the "Add Game" Button a new Game object should be initialized with the text from the EditText field and added to your game list. If the EditText is empty, then the Button should do nothing.  public void onClick(View v):  Check if the button is pressed  Add game title to the list CS440 5

Part 4: Add event listeners  Setup the onKey listener  public boolean onKey(View v, int KeyCode, KeyEvent event) :  Check if the key is pressed (ACTION_DOWN, KEYCODE_DPAD CENTER)  Add game title to the list CS440 6

Add event listeners with anonymous class (a different approach)  If you are unfamiliar with anonymous inner classes that's alright. Essentially, its an inline way of creating a one-time-use class that implements some interface. You declare the class and instantiate it in one motion. You can read more about them from Sun's Java Tutorials on Anonymous Inner Classes.  Copy the following code: CS440 7 GameButton.setOnClickListener(new OnClickListener() public void onClick(View view) { //Implement code to add a new game here... } });

Part 4: Add event listeners  Fill in the onClick method in the anonymous inner class that you created to add a new game to the list.  Retrieve the text entered by the user into the EditText by calling getText().toString() (Check for empty strings here).  Clear the EditText.  Call your addGame method  Call initAddGameListeners from onCreate.  Run your application to ensure that the "Add Game" Button functions properly. CS440 8

References  Professional Android 2 Application Development (Wrox Programmer to Programmer) by Reto Meier CS440 9