Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mobile Computing With Android ACST 4550 XML and the Android GUI

Similar presentations


Presentation on theme: "Mobile Computing With Android ACST 4550 XML and the Android GUI"— Presentation transcript:

1 Mobile Computing With Android ACST 4550 XML and the Android GUI

2 What is XML? eXtensible Markup Language
Markup language for documents containing structured information Based on Standard Generalized Markup Language (SGML) Version 1.0 introduced by World Wide Web Consortium (W3C) in 1998 Bridge for data exchange on the Web

3 XML HTML XML to HTML Comparison Extensible set of tags
Content orientated Standard Data infrastructure Allows multiple output forms Fixed set of tags Presentation oriented No data validation capabilities Single presentation

4 Authoring XML Elements
An XML element is made up of a start tag, an end tag, and data in between. Example: <director> Matthew Dunn </director> Example of another element with the same value: <actor> Matthew Dunn </actor> XML tags are case-sensitive: <CITY> <City> <city> XML can abbreviate empty elements, for example: <married> </married> can be abbreviated to <married/>

5 Authoring XML Elements (cont’d)
An attribute is a name-value pair separated by an equal sign (=). Example: <City ZIP=“94608”> Emeryville </City> Attributes are used to attach additional, secondary information to an element.

6 Authoring XML Documents
A basic XML document is an XML element that can, but might not, include nested XML elements. Example: <books> <book isbn=“123”> <title> Second Chance </title> <author> Matthew Dunn </author> </book> </books>

7 XML Data Model: Example
<BOOKS> <book id=“123” loc=“library”> <author>Hull</author> <title>California</title> <year> 1995 </year> </book> <article id=“555” ref=“123”> <author>Su</author> <title> Purdue</title> </article> </BOOKS> Purdue BOOKS 123 555 California Su title author article book year 1995 ref loc=“library” Hull

8 Apps – Android Manifest
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <application <activity android:name=".HelloAndroid" <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> @2011 Mihail L. Sichitiu

9 Apps – res (Resources) Folder
anim drawable hdpi mdpi ldpi layout values arrays.xml colors.xml strings.xml xml raw

10 Apps – R.java Autogenerated, best if not manually edited gen/

11 Apps – View Hierarchy All the views in a window are arranged in a tree
You show the tree by calling setContentView(rootNode) in the activity @2011 Mihail L. Sichitiu

12 Apps – Layout Defines how elements are positioned relative to each other (next to each other, under each other, in a table, grid, etc.) Can have a different layouts for each ViewGroup @2011 Mihail L. Sichitiu

13 Apps – Widgets All are View objects Examples: TextFields EditFields
Buttons Checkboxes RadioButtons etc. @2011 Mihail L. Sichitiu

14 UI Events Usually handled by defining a Listener of the form On<something>Listener and register it with the View For example: OnClickListener() for handling clicks on Buttons or Lists OnTouchListener() for handling touches OnKeyListener() for handling key presses Alternatively, Override an existing callback if we implemented our own class extending View @2011 Mihail L. Sichitiu

15 Create the following Android App: SimpleCalculator Name your Activity: CalculatorActivity

16 You will create the following GUI:


Download ppt "Mobile Computing With Android ACST 4550 XML and the Android GUI"

Similar presentations


Ads by Google