Tap on an item to bring up a piece of
Toast
containing a bigger version of the photo.
MainActivity.java
Helper.java
images/R.java
creates the
int
variables
R.drawable.sample_0
,
R.drawable.sample_1
,
etc.
appcompat/R.java
activity_main.xml
.
The
RelativeLayout
contains a
ListView
.
image_list_item.xml
contains a horizontal
LinearLayout
.
values/dimens.xml
sample_0.jpg
(213 × 285 pixels)sample_1.jpg
(285 × 213)sample_2.jpg
(285 × 191)sample_3.jpg
(285 × 213)sample_4.jpg
(285 × 190)sample_5.jpg
(191 × 285)sample_6.jpg
(285 × 213)sample_7.jpg
(213 × 285)sample_thumb_0.jpg
(45 × 60).
sample_thumb_1.jpg
(60 × 45)
sample_thumb_2.jpg
(60 × 40)
sample_thumb_3.jpg
(60 × 45)
sample_thumb_4.jpg
(60 × 40)
sample_thumb_5.jpg
(40 × 60)
sample_thumb_6.jpg
(60 × 45)
sample_thumb_7.jpg
(45 × 60)
AndroidManifest.xml
build.gradle
(Module: app)
In the Macintosh Finder,
control-click on each
.jpg
file and select Copy.
In the Android Studio
project
view, select
the folder
app/res/drawable
,
control-click on it,
and select Paste.
In the Android Studio
project
view,
select the folder
app/java/edu.nyu.scps.gridview
.
File →
New… →
Java Class
Create New Class
Name: Helper
Kind: Class
OK
In the new file
Helper.java
,
click on the word
Helper
and pull down
Code → Implement Methods…
Select
onCreate
and
onCreate
and press OK.
Pull down
Code → Generate… → Constructor
Select the constructor with only four arguments and press OK.
In the Android Studio
project
view,
select the folder
app/res/layout
and pull down
File → New → Layout resource file
New Resource File
File name: image_list_item
Root element: LinearLayout
OK