AppBasics
-
Upload
majd-yassin -
Category
Documents
-
view
216 -
download
0
Transcript of AppBasics
-
8/7/2019 AppBasics
1/13
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.
-
8/7/2019 AppBasics
2/13
A First Example: Advent Devotions
-
8/7/2019 AppBasics
3/13
UML Class Diagram
Generated by Android
External Activity
-
8/7/2019 AppBasics
4/13
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);
-
8/7/2019 AppBasics
5/13
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);
-
8/7/2019 AppBasics
6/13
Launching an Intent you didnt 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);
-
8/7/2019 AppBasics
7/13
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 yourUI with
setContentView(View).
http://developer.android.com/reference/android/app/
Activity.html#ActivityLifecycle
-
8/7/2019 AppBasics
8/13
AndroidManifest.xml
-
8/7/2019 AppBasics
9/13
Look around the files
-
8/7/2019 AppBasics
10/13
Layouts andR
esources 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
-
8/7/2019 AppBasics
11/13
main.xml
-
8/7/2019 AppBasics
12/13
devo.xml
-
8/7/2019 AppBasics
13/13
dimens.xml
17sp
20sp
Hello World, AdventDevos!
Advent Devotions
#AAFFFF99
#FF000000
colors.xml
strings.xml