150 likes | 354 Views
Programski jezici za mobilne aplikacije. Ivana Šimić, 875 Katarina Vincetić, 898. Uvod. Početci: Apple – iPhone (2007.). Objective C C#. Java C/C++. Visual C++ C/C++. Java. Android OS. Operativni sustav Linux Android Inc. Google 2005. Open source projekt Java, XML, HTML5. Java.
E N D
Programski jezici za mobilne aplikacije Ivana Šimić, 875 Katarina Vincetić, 898
Uvod • Početci: Apple – iPhone (2007.) • Objective C • C# • Java • C/C++ • Visual C++ • C/C++ • Java
Android OS • Operativni sustav • Linux • Android Inc. Google 2005. • Open source projekt • Java, XML, HTML5
Java • James Gosling 1995. • Java Virtual Machine (JVM) class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } }
Programiranje mobilnih aplikacija za Android OS • Nativne aplikacije: • Izgled – XML • Događaji – Java + C/C++ • Web aplikacije: HTML5 + CSS3 uz JavaScript • Eclipse • Primjer: konverter (kn, €)
Primjer 1. dio (XML) <?xmlversion="1.0"encoding="utf-8"?> <RelativeLayout android:id="@+id/RelativeLayout01" android:layout_width="fill_parent„ android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> /* Ovdje ubacujemo elemente */ </RelativeLayout>
Primjer 2. dio (XML) <LinearLayout android:layout_alignParentTop="true"android:layout_width="200dp"android:orientation="vertical"android:layout_height="280dp"android:id="@+id/linearlayoutId"> /* Ovdje ubacujemo elemente */ </LinearLayout> <TextViewandroid:id="@+id/TextView01"android:layout_width="wrap_content"android:layout_height="wrap_content„ android:text="Kune"android:textStyle="bold"></TextView> <EditTextandroid:layout_width="100dp"android:layout_height="45dp"android:id="@+id/kn"android:lines="1"></EditText>
Primjer 3. dio (XML) <RadioGroupandroid:id="@+id/RadioGroup01"android:layout_width="wrap_content"android:layout_height="wrap_content"><RadioButtonandroid:layout_width="wrap_content"android:layout_height="wrap_content" android:text="Kune u eure"android:id="@+id/knUe"></RadioButton><RadioButtonandroid:layout_width="wrap_content"android:layout_height="wrap_content" android:text="Euri u kune"android:id="@+id/eUkn"></RadioButton>
Primjer 4. dio (XML) <Buttonandroid:layout_height="wrap_content"android:layout_width="wrap_content"android:layout_below="@+id/linearlayoutId"android:layout_alignRight="@+id/linearlayoutId"android:text="Pretvori"android:id="@+id/pretvori"></Button> • Gotov izgled!
Primjer 5. dio (Java) package com.droidbd.currencyconverter; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; public class CurrencyConverter extends Activity implements OnClickListener { EditText kn; EditText euri; RadioButton knUe; RadioButton eUkn; Button pretvori; /*ovdje pišemo funkcije*/ }
Primjer 6. dio (Java) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); kn = (EditText)findViewById(R.id.kn); euri = (EditText)findViewById(R.id.euri); knUe = (RadioButton)this.findViewById(R.id.knUe); knUe.setChecked(true); eUkn = (RadioButton)this.findViewById(R.id.eUkn); pretvori = (Button)this.findViewById(R.id.pretvori); pretvori.setOnClickListener(this); }
Primjer 7. dio (Java) public void onClick(View arg0) { if (knUe.isChecked()) { kn_e(); } if (eUkn.isChecked()) { e_kn(); } } protected void e_kn() { double val = Double.parseDouble(euri.getText().toString()); kn.setText(String.format( "%.2f", val*7.56 )); }
HTML5 • Inačica HTML-a • <canvas> • <audio> • <video> • <article> • <header> • ...
Zaključak • Operativni sustavi za mobilne uređaje • Nativne i web aplikacije • Android: • Nativne: Java, C/C++, XML • Web: HTML5, CSS3
Literatura • Kim W. Tracy, Mobile application development experiences on Apple's iOS 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/currencyconverter-tutorial/ (3.1.2013.) • David Meyer, Mobile Application Development: Must Know Key Point Aspects, http://www.webgranth.com/mobile-application-development-must-know-key-point-aspects (3.1.2013.) • HTML5 introduction, http://www.w3schools.com/html/html5_intro.asp (4.1.2013.)