ANDROID APPS DEVELOPMENT FOR MOBILE GAME

Similar documents
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

Overview. What are layouts Creating and using layouts Common layouts and examples Layout parameters Types of views Event listeners

Praktikum Entwicklung Mediensysteme. Implementing a User Interface

Android Apps Development for Mobile and Tablet Device (Level I) Lesson 2

User Interface: Layout. Asst. Prof. Dr. Kanda Runapongsa Saikaew Computer Engineering Khon Kaen University

Hello World. Lesson 1. Android Developer Fundamentals. Android Developer Fundamentals. Layouts, and. NonCommercial

Mobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling

Programming with Android: Layouts, Widgets and Events. Dipartimento di Scienze dell Informazione Università di Bologna

Lab 1 - Setting up the User s Profile UI

ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)

TextView. A label is called a TextView. TextViews are typically used to display a caption TextViews are not editable, therefore they take no input

CS260 Intro to Java & Android 05.Android UI(Part I)

04. Learn the basic widget. DKU-MUST Mobile ICT Education Center

CS378 -Mobile Computing. User Interface Basics

CS260 Intro to Java & Android 05.Android UI(Part I)

CS371m - Mobile Computing. User Interface Basics

ANDROID USER INTERFACE

Mobile Application Development Android

Creating a User Interface

CS 4518 Mobile and Ubiquitous Computing Lecture 2: Introduction to Android Programming. Emmanuel Agu

Android User Interface Android Smartphone Programming. Outline University of Freiburg

Mobile User Interfaces

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Introduction to Android Programming. Emmanuel Agu

Android User Interface

LECTURE 08 UI AND EVENT HANDLING

Android UI: Overview

CS 528 Mobile and Ubiquitous Computing Lecture 2a: Android UI Design in XML + Examples. Emmanuel Agu

Android Basics. Android UI Architecture. Android UI 1

Android Programming Lecture 2 9/7/2011

Programming with Android: Widgets and Events. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna

Produced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology

Building User Interface for Android Mobile Applications II

Android Application Development

Android User Interface Overview. Most of the material in this sec7on comes from h8p://developer.android.com/guide/topics/ui/index.

Questions and Answers. Q.1) Which of the following is the most ^aeuroeresource hungry ^aeuroepart of dealing with activities on android?

Android Application Development 101. Jason Chen Google I/O 2008

GUI Design for Android Applications

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University. Overview (Review)

Android Programming (5 Days)

A view is a widget that has an appearance on screen. A view derives from the base class android.view.view.

EECS 4443 Mobile User Interfaces. More About Layouts. Scott MacKenzie. York University

Android Development Crash Course

Programming Android UI. J. Serrat Software Design December 2017

Required Core Java for Android application development

MC Android Programming

Produced by. Mobile Application Development. Eamonn de Leastar

Android UI Development

Mobile Programming Lecture 1. Getting Started

07. Menu and Dialog Box. DKU-MUST Mobile ICT Education Center

(c) Dr Sonia Sail LAJMI College of Computer Sciences & IT (girl Section) 1

Stanislav Rost CSAIL, MIT

Android App Development. Mr. Michaud ICE Programs Georgia Institute of Technology

06. Advanced Widget. DKU-MUST Mobile ICT Education Center

Mobile and Ubiquitous Computing: Android Programming (part 3)

ConstraintLayouts in Android

Graphical User Interfaces

GUI Widget. Lecture6

Embedded Systems Programming - PA8001

MOBILE COMPUTING 1/20/18. How many of you. CSE 40814/60814 Spring have implemented a command-line user interface?

Comparative Study on Layout and Drawable Resource Behavior in Android for Supporting Multi Screen

Views & View Events View Groups, AdapterViews & Layouts Menus & ActionBar Dialogs

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

Beginning Android 4 Application Development

Syllabus- Java + Android. Java Fundamentals

Mobila applikationer och trådlösa nät, HI1033, HT2012

ListView (link) An ordered collection of selectable choices. key attributes in XML:

CS 4518 Mobile and Ubiquitous Computing Lecture 5: Data-Driven Views and Android Components Emmanuel Agu

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

ListView Containers. Resources. Creating a ListView

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

South Africa

Introductory Android Development

Programming with Android: Introduction. Layouts. Dipartimento di Informatica: Scienza e Ingegneria Università di Bologna

Programming in Android. Nick Bopp

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu

Android Basics. - Bhaumik Shukla Android Application STEALTH FLASH

Activities and Fragments

Fragments. Lecture 11

Mobile Software Development for Android - I397

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

Mobile Programming Lecture 3. Resources, Selection, Activities, Intents

CS 528 Mobile and Ubiquitous Computing Lecture 2: Intro to Android Programming Emmanuel Agu

Android for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011

Practical Problem: Create an Android app that having following layouts.

CS 234/334 Lab 1: Android Jump Start

Android Application Model I

Spring Lecture 4 Lecturer: Omid Jafarinezhad

Android App Development

14.1 Overview of Android

Fragments. Lecture 10

UI, Continued. CS 2046 Mobile Application Development Fall Jeff Davidson CS 2046

CS 528 Mobile and Ubiquitous Computing Lecture 1b: Introduction to Android. Emmanuel Agu

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments

User Interface Design & Development

Mobila applikationer och trådlösa nät, HI1033, HT2013

Mobile Computing Professor Pushpedra Singh Indraprasth Institute of Information Technology Delhi Andriod Development Lecture 09

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Transcription:

ANDROID APPS DEVELOPMENT FOR MOBILE GAME Application Components Hold the content of a message (E.g. convey a request for an activity to present an image) Lecture 2: Android Layout and Permission Present a visual user interface for one focused endeavor the user can undertake (E.g. list of menu items) Run in the background for an indefinite period of time (E.g. calculate and provide the result to activities that need it) Peter Lo Receive and react to broadcast announcements (E.g. announcements that the time zone has changed) Store and retrieve data and make it accessible to all applications (E.g. audio, video, images, etc.) 2 Simple Android App Layout Android Layouts A layout defines the visual structure for a user interface: Declare UI elements in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. Instantiate layout elements at runtime. Your application can create View and ViewGroup objects programmatically. An Android layout is a class that handles arranging the way its children appear on the screen. Anything that is a View can be a child of a layout. All of the layouts inherit from ViewGroup so you can nest layouts. AbsoluteLayout FrameLayout LinearLayout RelativeLayout TableLayout Create Layout by Drag and Drug Create Layout by Typing XML 3 4

Linear Layout Relative Layout In a linear layout, all the elements are displayed in a linear fashion, either Horizontally or Vertically The properties is set in android:orientation which is an attribute of the node LinearLayout. In a relative layout every element arranges itself relative to other elements or a parent element. E.g. The Cancel button is placed relatively, to the right of the Login button parallel. Here is the code snippet that achieves the mentioned alignment 5 6 Table Layout Layout Attributes Table layouts in Android works in the same way HTML table layouts work. You can divide your layouts into rows and columns. FILL_PARENT / MATCH_PARENT, which means that the view wants to be as big as its parent (minus padding) WRAP_CONTENT, which means that the view wants to be just big enough to enclose its content (plus padding) 7 8

The View Hierarchy Using Views The view hierarchy diagram gives probably the clearest overview of the relationship between the various views that make up the user interface shown. When a user interface is displayed to the user, the Android runtime walks the view hierarchy, starting at the root view and working down the tree as it renders each view. Dealing with widgets & layouts typically involves the following operations Set properties Set up listeners Set focus Set visibility 9 10 Event Listener TextView (Label) An object cannot process event on its own, it needs a listener for this. E.g. When a button is clicked, listener reacts and runs the code from onclick method. A label is called in android a TextView. TextViews are not editable, typically used for output to display a caption. Common Event onclick() onlongclick() onfocuschange() onkey() ontouch() 11 oncreatecontextmenu() 12

Button EditText (Text Field) A Button widget allows the simulation of a clicking action on a GUI. Button is a subclass of TextView, it styled using the system's default button background. Request a reference to the button from the activity by calling findviewbyid. EditText allows the user to type text (single text or multiline) into your app. Touching a text field places the cursor and automatically displays the keyboard. Request a reference to the button from the activity by calling findviewbyid. Create a class implementing OnClickListener and set it as the on click listener for the button. 13 Retrieve the EditText value and convert to string 14 Common InputType for EditText Radio Button text number phone textmultiline textcapcharacters Radio buttons allow the user to select one option from a set. You should use radio buttons for optional sets that are mutually exclusive if you think that the user needs to see all available options side-by-side. To create each radio button option, create a RadioButton in your layout. However, because radio buttons are mutually exclusive, you must group them together inside a RadioGroup. By grouping them together, the system ensures that only one radio button can be selected at a time textpassword textautocorrect 15 16

Handling Events in Radio Button Checkbox RadioButton radio0 = (RadioButton) findviewbyid(r.id.radio0); RadioButton radio1 = (RadioButton) findviewbyid(r.id.radio1); RadioGroup radiogroup1 = (RadioGroup) findviewbyid(r.id.radiogroup1); radiogroup1.setoncheckedchangelistener( new RadioGroup.OnCheckedChangeListener() { public void oncheckedchanged ( RadioGroup group, int checkedid ) { if ( checkedid == radio0.getid() ) { else if ( checkedid == radio1.getid() ) { ); Checkboxes allow the user to select one or more options from a set. Typically, you should present each checkbox option in a vertical list. To create each checkbox option, create a CheckBox in your layout. Because a set of checkbox options allows the user to select multiple items, each checkbox is managed separately and you must register a click listener for each one. 17 18 Handling Events in Checkbox Toast (Message) CheckBox checkbox1 = (CheckBox) findviewbyid(r.id.checkbox1); if (checkbox1.ischecked()) { else { Toast messages is a simple pop-up message for alerting users. The following code would generate a toast message: Toast.makeText(Context, Text, Duration).show(); CheckBox checkbox2 = (CheckBox) findviewbyid(r.id.checkbox2); if (checkbox2.ischecked()) { The context to use, usually your Application or Activity object by method getapplicationcontext() Duration for the message display: LENGTH_SHORT (2 seconds) LENGTH_LONG (3.5 seconds) else { The text to show on screen 19 20

Using Permissions Common Permission A basic Android application has no permissions associated with it by default, meaning it cannot do anything that would adversely impact the user experience or any data on the device. To make use of protected features of the device, you must include in your AndroidManifest.xml one or more <uses-permission> tags declaring the permissions that your application needs Permission ACCESS_FINE_LOCATION BLUETOOTH Description Allows an app to access precise location from location sources such as GPS, cell towers, and Wi-Fi. Allows applications to connect to paired Bluetooth devices The permissions provided by the Android system can be found at NFC Allows applications to perform I/O operations over NFC http://developer.android.com/reference/android/manifest.permission.html CALL_PHONE Allows an application to initiate a phone call without going through the Dialer user interface for the user to 21 confirm the call being placed. 22 CAMERA INTERNET READ_CONTACTS READ_EXTERNAL_STORAGE WRITE_EXTERNAL_STORAGE Required to be able to access the camera device. Allows applications to open network sockets. Allows an application to read the user's contacts data. Allows an application to read from external storage. Allows an application to write to external storage.