Unterlage zur Android Vorlesung "Programmierung von Apps" an der Hochschule Karlsruhe.
Die Studierenden
kennen die grundlegenden
Prinzipien, Patterns und Bestandteile
eines Android User Interface
und verstehen, wie damit effizient
eine Benutzeroberfläche erstellt
werden kann.
Mobile Dokumentation auf Tablet-PCs und Smartphones mithilfe von Apps
Android User Interface
1. Programmierung
von Apps
Android User Interface
Danny Fürniß, 12.11.2012, 1
2. Die Studierenden
kennen die grundlegenden
Prinzipien, Patterns und Bestandteile
eines Android User Interface
und verstehen, wie damit effizient
eine Benutzeroberfläche erstellt
werden kann.
Danny Fürniß, 12.11.2012, 2
25. deklarativ vs. prozedural
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout new LinearLayout()
<TextView new TextView()
android:id="@+id/textView1"
android:text="Dauer in Millisekunden"/>
<EditText new EditText()
android:id="@+id/delayTextView"
android:text="200" >
</EditText>
<Button new Button()
android:id="@+id/startTaskButton"
android:text="Starte LongRunningTask" />
Danny Fürniß, 12.11.2012, 26
</LinearLayout>
XML Java
26. android.view.View
View
Basisklasse aller UI Elemente
Danny Fürniß, 12.11.2012, 27
32. View Hierarchy
Danny Fürniß, 12.11.2012, 33
Max 10 Ebenen, Max 80 Views je Screen
Demo
Bildquelle: http://developer.android.com/guide/topics/ui/index.html
33. Danny Fürniß, 12.11.2012, 34
Bildquelle: http://android-developers.blogspot.de/2009/03/android-layout-tricks-3-optimize-by.html
50. Use Strict Mode
public void onCreate() {
if (DEVELOPER_MODE) {
StrictMode.setThreadPolicy(
new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork()
.penaltyLog()
.build());
StrictMode.setVmPolicy(
new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.detectLeakedClosableObjects()
.penaltyLog()
.penaltyDeath()
Danny Fürniß, 12.11.2012, 51
.build());
}
super.onCreate();
}
51. public class LongRunningAsyncTask extends AsyncTask<Params, Progress, Result> {
protected void onPreExecute() {
// Wird im UI-Thread ausgeführt.
}
protected Result doInBackground(Params... params) {
// Wird In einem neuen Background-Thread ausgeführt.
publishProgress(Progress)
return Result;
}
protected void onProgressUpdate(Progress... values) {
// Wird im UI-Thread ausgeführt.
}
protected void onPostExecute(Result result) {
// Wird im UI-Thread ausgeführt.
}
}
Danny Fürniß, 12.11.2012, 52
new LongRunningAsyncTask().execute(Params);
Demo
73. Portions of this presentation
are modifications based on
work created and shared by
Google and used according
to terms described in
the Creative Commons 3.0
Attribution License.
Danny Fürniß, 12.11.2012, 74