Programski jezici za mobilne aplikacije Ivana imi 875
Programski jezici za mobilne aplikacije Ivana Šimić, 875 Katarina Vincetić, 898
Uvod • Početci: Apple – i. Phone (2007. ) • Objective C • C# • Java • C/C++ • Visual C++ • C/C++ • Java 2
Android OS • Operativni sustav • Linux • Android Inc. Google 2005. • Open source projekt • Java, XML, HTML 5 3
Java • James Gosling 1995. • Java Virtual Machine (JVM) class Hello. World. App { public static void main(String[] args) { System. out. println("Hello World!"); } } 4
Programiranje mobilnih aplikacija za Android OS • Nativne aplikacije: – Izgled – XML – Događaji – Java + C/C++ • Web aplikacije: HTML 5 + CSS 3 uz Java. Script • Eclipse • Primjer: konverter (kn, €) 5
Primjer 1. dio (XML) <? xml version="1. 0" encoding="utf-8"? > <Relative. Layout android: id="@+id/Relative. Layout 01" android: layout_width="fill_parent„ android: layout_height="fill_parent" xmlns: android="http: //schemas. android. com/apk/res/android"> /* Ovdje ubacujemo elemente */ </Relative. Layout> 6
Primjer 2. dio (XML) <Linear. Layout android: layout_align. Parent. Top="true" android: layout_width="200 dp" android: orientation="vertical" android: layout_height="280 dp" android: id="@+id/linearlayout. Id"> /* Ovdje ubacujemo elemente */ </Linear. Layout> <Text. View android: id="@+id/Text. View 01" android: layout_width="wrap_content" android: layout_height="wrap_content„ android: text="Kune" android: text. Style="bold"></Text. View> <Edit. Text android: layout_width="100 dp" android: layout_height="45 dp" android: id="@+id/kn" android: lines="1"></Edit. Text> 7
Primjer 3. dio (XML) <Radio. Group android: id="@+id/Radio. Group 01" android: layout_width="wrap_content" android: layout_height="wrap_content"><Radio. Button android: layout_width="wrap_content" android: layout_height="wrap_content" android: text="Kune u eure" android: id="@+id/kn. Ue"></Radio. Button><Radio. Button android: layout_width="wrap_content" android: layout_height="wrap_content" android: text="Euri u kune" android: id="@+id/e. Ukn"></Radio. Button> 8
Primjer 4. dio (XML) <Button android: layout_height="wrap_content" android: layout_width="wrap_content" android: layout_below="@+id/linearlayout. Id" android: layout_align. Right="@+id/linearlayout. Id" android: text="Pretvori" android: id="@+id/pretvori"></Button> • Gotov izgled! 9
Primjer 5. dio (Java) package com. droidbd. currencyconverter; import android. app. Activity; import android. os. Bundle; import android. view. View. On. Click. Listener; import android. widget. Button; import android. widget. Edit. Text; import android. widget. Radio. Button; public class Currency. Converter extends Activity implements On. Click. Listener { Edit. Text kn; Edit. Text euri; Radio. Button kn. Ue; Radio. Button e. Ukn; Button pretvori; /*ovdje pišemo funkcije*/ } 10
Primjer 6. dio (Java) public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); set. Content. View(R. layout. main); kn = (Edit. Text)find. View. By. Id(R. id. kn); euri = (Edit. Text)find. View. By. Id(R. id. euri); kn. Ue = (Radio. Button)this. find. View. By. Id(R. id. kn. Ue); kn. Ue. set. Checked(true); e. Ukn = (Radio. Button)this. find. View. By. Id(R. id. e. Ukn); } pretvori = (Button)this. find. View. By. Id(R. id. pretvori); pretvori. set. On. Click. Listener(this); 11
Primjer 7. dio (Java) public void on. Click(View arg 0) { if (kn. Ue. is. Checked()) { kn_e(); } if (e. Ukn. is. Checked()) { e_kn(); } } protected void e_kn() { double val = Double. parse. Double(euri. get. Text(). to. String()); kn. set. Text(String. format( "%. 2 f", val*7. 56 )); } 12
HTML 5 • Inačica HTML-a • • • <canvas> <audio> <video> <article> <header>. . . <!DOCTYPE html> <head> <title>Naslov dokumenta </title> </head> <body> Tijelo dokumenta. . . </body> </html> 13
Zaključak • Operativni sustavi za mobilne uređaje • Nativne i web aplikacije • Android: – Nativne: Java, C/C++, XML – Web: HTML 5, CSS 3 14
Literatura • Kim W. Tracy, Mobile application development experiences on Apple's i. OS and Android OS, 2011 • Android - Discover Android, http: //www. android. com/about/ (4. 1. 2013. ) • Android Technical Information | Android Open Source, http: //source. android. com/about/philosophy. html (4. 1. 2013. ) • Android Tutorial - How to create a GUI application in Android, http: //www. skill-guru. com/blog/2011/01/18/currencyconvertertutorial/ (3. 1. 2013. ) • David Meyer, Mobile Application Development: Must Know Key Point Aspects, http: //www. webgranth. com/mobileapplication-development-must-know-key-point-aspects (3. 1. 2013. ) • HTML 5 introduction, http: //www. w 3 schools. com/html 5_intro. asp (4. 1. 2013. ) 15
- Slides: 15