Professional Documents
Culture Documents
Stephen Gilmore
School of Informatics
September 28, 2017
Contents
1. Android concepts
2. Android projects
3. Android Studio
1
Android concepts
Activities and contexts
java.lang.Object
android.content.Context (abstract class)
android.content.ContextWrapper
android.view.ContextThemeWrapper
android.app.Activity
3
Sample onCreate method create UI components
4
Sample onCreate method create UI components
5
Sample toolbar and button definition in XML
res/layout/activity main.xml
<android.support.v7.widget.Toolbar
android:id=@+id/toolbar
android:layout width=match parent
android:layout height=?attr/actionBarSize
android:background=?attr/colorPrimary
app:popupTheme=@style/AppTheme.PopupOverlay />
...
<android.support.design.widget.FloatingActionButton
android:id=@+id/fab
android:layout width=wrap content
android:layout height=wrap content
android:layout gravity=bottom|end
android:layout margin=@dimen/fab margin
android:tint=@android:color/white
app:srcCompat=@android:drawable/ic input add />
6
Android Activity lifecycle
From https://developer.android.com/training/basics/
activity-lifecycle/starting.html
7
Android Activity lifecycle (create)
From https://developer.android.com/training/basics/
activity-lifecycle/starting.html
8
Android Activity lifecycle (paused)
From https://developer.android.com/training/basics/
activity-lifecycle/pausing.html
9
Android Activity lifecycle (stopping)
From https://developer.android.com/training/basics/
activity-lifecycle/stoping.html
10
Android Activity lifecycle (saving state)
From https://developer.android.com/training/basics/
activity-lifecycle/recreating.html
11
Adding a new Activity
12
Using Intents
Image from
http://www.vogella.com/tutorials/AndroidIntent/article.html
13
Using Intents
14
Simple switch to another activity
15
Simple switch to another activity
15
One mechanism of activity starting another
From https:
//developer.android.com/guide/components/intents-filters.html
16
Passing information to another activity (sender)
17
Passing information to another activity (sender)
17
Passing information to another activity (receiver)
if (textView.parent != null)
(textView.parent as ViewGroup).removeView(textView)
setContentView(textView)
}
} obj as class is Kotlin syntax for a cast.
18
Android projects
Android projects
19
Android build files
21
Android Studio
23
Links
24