Presentation is loading. Please wait.

Presentation is loading. Please wait.

CE53105-3 Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running.

Similar presentations


Presentation on theme: "CE53105-3 Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running."— Presentation transcript:

1 CE53105-3 Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running programs DDMS ( Dalvik Debug Monitor Server ) Explaining Interesting things in Notes3

2 Android File Structure Source folder – all java files you create Your Project – Should be a unique name Individual Java source files Generated folder – R class here – leave alone Resource folder – XML files defining resources Source objects for Android platform target The Manifest – Declares all bits of project Drawable Folders – Picture, image, icons etc Values folder – In this case a strings XML doc Layout XML files – Used by Activities to define screens

3 Drawable Folders Contains images that will be used in your programs – Generally three (or one) Drawable-hdpi – high resolution screen Drawable –mdpi – medium resolution Drawable- ldpi – low resolution – Means you may need several versions of your image to suit the screen resolution! Becoming a problem as sizes proliferate Referenced using the R class

4 Layout folder Contains XML documents that define the layout of a particular view. Activity’s utilise views by the setcontextview statement. – setContentView(R.layout.tigger1); Layouts can be complex and difficult to build – DroidDraw - http://www.droiddraw.org ?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" />

5 Values Files containing tuples of data – name and value Name – Hello value – Hello World Can be simple or complex data items – Arrays, menus etc Hello World, Viewdemo! Viewdemo Bahrain Bangladesh Barbados Belarus Belgium Belize Benin

6 The R Class contains resource IDs for all the resources in your res/ directory – Generated by aapt (Android Asset Packaging Tool) – For each type of resource, there is an R subclass – for each resource of that type, there is a static integer – To use the resource simply add it to your code R.string.hello or 0x7f040000 R.layout.linearlayoutdemo or 0x7f030000 R.array.countries_array or 0x7f050000 Means that you can change details without having to change the code! /* AUTO-GENERATED FILE. DO NOT MODIFY. package ac.uk.ere1.Viewdemo; public final class R { public static final class array { public static final int countries_array=0x7f050000; } public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int entry=0x7f060001; public static final int label=0x7f060000; public static final int ok=0x7f060002; } public static final class layout { public static final int linearlayoutdemo=0x7f030000; public static final int list_item=0x7f030001; public static final int main=0x7f030002; public static final int relativelayoutdemo=0x7f030003; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; }

7 The DDMS Perspective Emulators Running Emulator controls – can simulate various phone actions eg receiving a call or gaining GPS input Directory Structure of emulator (can push and pull files) Log provides useful information on what is happening live!

8 Android Manifest <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ac.uk.ere1.Viewdemo" android:versionCode="1" android:versionName="1.0“ <activity android:name=".Viewdemo" android:label="@string/app_name"> <activity android:name="Listview" /> <activity android:name="Linearlayout" /> <activity android:name="Relativelayout" /> <!-- <activity android:name="Tablelayout" /> --> Package definition Intent Filter defines what it can do Permissions Required Activities Commented out Activities

9 Notepadv3 Key Points

10 Notepadv3 (cont) 1- @overide – places an existing definition of the method. 2- super is the root definition and is called to ensure all methods and properties are properly instantiated. 3- setContentview(R.layout.notes_list) – used to define the view being used by the activity. In this case note_list! 4- a- call to a method defined in this class. b- the method definition. 5- Intent starting a new activity (ACTIVITY_CREATE) Note it expects the activity to return a result! 6- Intent starting a new activity (ACTIVITY_EDIT) Also expecting a result to be returned. Note i.putExtra method – allows data to be transmitted to activity. 7- The method dealing with the result returned. 8- Have to create ‘listeners’ for each view item – problematical!


Download ppt "CE53105-3 Applied Communications Technology Android lecture 2 - Structures Android File structure Resources Drawables Layout Values R Class Manifest Running."

Similar presentations


Ads by Google