1
00:00:03,760 --> 00:00:09,760
G'day everyone. Welcome back, and welcome to
section 14. In this section, we're going

2
00:00:09,760 --> 00:00:15,580
to create a settings dialog for the app.
Android Studio will generate a Settings

3
00:00:15,580 --> 00:00:20,860
Activity for you, but I'm not going to
use one. If you want to experiment with it,

4
00:00:20,860 --> 00:00:34,680
you can find a Google guide at https://developer.android.com/guide/topics/ui/settings/

5
00:00:34,680 --> 00:00:37,440
You can create a
SettingsActivity by right-clicking the

6
00:00:37,440 --> 00:00:42,680
project name and choosing New, Activity.

7
00:00:46,520 --> 00:00:50,900
Near the bottom of the list, there's a
SettingsActivity.

8
00:00:54,120 --> 00:00:57,930
There are a lot of examples online, which
is one reason I'm not going to use a

9
00:00:57,930 --> 00:01:03,360
SettingsActivity here. Another reason is,
we want the users to be able to change

10
00:01:03,360 --> 00:01:07,800
things like the starting day of the week,
while they're viewing the report.

11
00:01:07,800 --> 00:01:12,540
A dialogue is more appropriate for that,
because displaying a dialogue doesn't

12
00:01:12,540 --> 00:01:18,000
involve leaving the Activity. Something
else we'll do, is use a Preference Listener.

13
00:01:18,000 --> 00:01:21,630
If the user does decide to change the starting day of the week, from

14
00:01:21,630 --> 00:01:26,010
Sunday to Monday for example, then any
report they're viewing should update

15
00:01:26,010 --> 00:01:30,570
straight away. Whenever the preferences
change, anything listening will be

16
00:01:30,570 --> 00:01:35,220
notified of the change. That's much
better than asking the user to restart

17
00:01:35,220 --> 00:01:40,560
the app, when they change a configuration
setting. If you followed along with

18
00:01:40,560 --> 00:01:46,880
those menu options and started to create
a SettingsActivity, click cancel.

19
00:01:46,880 --> 00:01:52,100
We're gonna create a settings dialog instead.
Okay, we're going to use string

20
00:01:52,110 --> 00:01:56,940
resources for all the text, and to save
typing, I'm gonna paste all the resources

21
00:01:56,940 --> 00:02:01,380
into a resource file. We've created
enough string resources for now, and I'm

22
00:02:01,380 --> 00:02:05,340
sure you don't want to watch me type in
more than necessary. I'll create a new

23
00:02:05,340 --> 00:02:08,990
values resource file

24
00:02:15,430 --> 00:02:20,230
called strings underscore settings.

25
00:02:21,430 --> 00:02:30,140
That'll be in the values folder and then
we'll paste in the resources. You'll find

26
00:02:30,140 --> 00:02:34,700
the complete settings underscore
strings.xml file in the resources for

27
00:02:34,700 --> 00:02:37,800
this video, to save you doing the typing as well.

28
00:02:37,800 --> 00:02:41,900
There's nothing special about the names
of these resource files, and you can

29
00:02:41,900 --> 00:02:46,640
create new files to organize things like
your string resources. When your app is

30
00:02:46,640 --> 00:02:51,950
built, all the XML files combined into a
single resource file, and we looked at

31
00:02:51,950 --> 00:02:56,690
the R class earlier in the course. I'm
going to talk about those plurals

32
00:02:56,690 --> 00:03:01,459
resources later, after we've seen them
being used. We'll make a start on the

33
00:03:01,459 --> 00:03:06,879
settings layout, in the next video. See
you there.

