Ask the 8 Ball a question and tap the screen. Then do it again.
The
action bar
of the
MarkActivity
has a left arrow leading to the
MainActivity
because we said that the
MainActivity
was the hierarchical parent of the
MarkActivity
when we created the
MarkActivity
.
See
Navigation
with Back and Up
and
Navigating
Up
with the App Icon.
MainActivity.java
.
The
ListView
has an
AdapterView.OnItemClickListener
.
activity_main.xml
MarkActivity.java
.
The dark blue
RelativeLayout
has a
View.OnTouchListener
which feeds a
GestureDetector
that detects a single tap.
activity_mark.xml
strings.xml
contains a
string
array
resource used by the
ListView
’s
ArrayAdapter<CharSequence>
.
I changed the
app_name
to
Jul11 Mark
.
AndroidManifest.xml
contains an
<activity>
element
for each
Activity
class.
build.gradle
(Module: app)
Follow the instructions in Collective for creating the second activity.
String
s
in
MarkActivity
with the following
string
array resource
in
strings.xml
.
<string-array name="answers_array"> <item>It is certain.</item> <item>It is decidedly so.</item> <item>Without a doubt.</item> <item>Yes, definitely.</item> <item>You may rely on it.</item> <item>As I see it, yes.</item> <item>Most likely.</item> <item>Outlook good.</item> <item>Yes.</item> <item>Signs point to yes.</item> <item>Reply hazy. Try again.</item> <item>Ask again later.</item> <item>Better not tell you now.</item> <item>Cannot predict now.</item> <item>Concentrate and ask again.</item> <item>Don\u2019t count on it.</item> <!-- Unicode apostrophe --> <item>My reply is no.</item> <item>My sources say no.</item> <item>Outlook not so good.</item> <item>Very doubtful.</item> </string-array>Change the
answers
field of class
MarkActivity
to the following.
private static String[] answers;Initialize
answers
in the
onCreate
method of class
MarkActivity
after the
setContentView
.
Resources resources = getResources(); answers = resources.getStringArray(R.array.answers_array);