Download presentation
Presentation is loading. Please wait.
Published byAshlie Lloyd Modified over 9 years ago
1
Android App Basics Dr. David Janzen Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution 2.5 License.
2
A First Example: Advent Devotions
3
UML Class Diagram Generated by Android External Activity
4
Two Activities in Advent Devotions AdventDevos displays the calendar of dates Devo displays a single devotion Intent myIntent = new Intent(AdventDevos.this, Devo.class); myIntent.putExtra("ButtonNum", "" + index); startActivity(myIntent);
5
Two Activities in Advent Devotions AdventDevos displays the calendar of dates Devo displays a single devotion Bundle extras = getIntent().getExtras(); String value = extras.getString("ButtonNum"); Integer buttonNum = Integer.valueOf(value);
6
Launching an Intent you didn’t write Devos has button to URL Browser launched Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.biblegateway.com/passage/?search="+ passage +"&version=NIV")); startActivity(i);
7
Android Activity “An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).” http://developer.android.com/reference/android/app/ Activity.html#ActivityLifecycle
8
AndroidManifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.simexusa.adventdevotions" android:versionCode="2" android:versionName="1.0"> <activity android:name=".AdventDevos" android:label="@string/app_name"> Specifies icon for launching app Specifies activity to be launched at startup Each upload to Market requires versionCode increment Security permissions requested from user on install
9
Look around the files
10
Layouts and Resources See main.xml and devo.xml –Activity associates with layout xml file using setContentView(R.layout.main); or setContentView(R.layout.devo); in onCreate() –Note TableLayout and TableRow similar to and in html –Note use of dimen (see values/dimens.xml) and color (see values/colors.xml) –Also see strings.xml
11
main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/background"> <TableLayout android:layout_width="wrap_content" android:id="@+id/TableLayout01" android:layout_height="wrap_content"> <Button android:text="Nov. 29" android:id="@+id/Button01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/button_width"> <Button android:text="Nov. 30" android:id="@+id/Button02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/button_width"> <Button android:text="Dec. 1" android:id="@+id/Button03" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/button_width"> <Button android:text="Dec. 2" android:id="@+id/Button04" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="@dimen/button_width"> …
12
devo.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" android:background="@color/background"> <TextView android:text="Date" android:id="@+id/Date" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textStyle="italic" android:textSize="@dimen/reference_width" android:typeface="serif" android:textColor="@color/text"> <TextView android:text="Title" android:id="@+id/Title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textStyle="bold" android:textSize="@dimen/reference_width" android:typeface="serif" android:textColor="@color/text"> <Button android:text="Read Scripture" android:id="@+id/ButtonScripture" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:textSize="@dimen/reference_width"> <ScrollView android:id="@+id/ScrollView01" android:layout_height="fill_parent" android:layout_width="fill_parent"> <TextView android:text="Body" android:id="@+id/Body" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="left" android:textSize="@dimen/reference_width" android:typeface="serif" android:textColor="@color/text">
13
dimens.xml 17sp 20sp Hello World, AdventDevos! Advent Devotions #AAFFFF99 #FF000000 colors.xml strings.xml
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.