Skip to main content

Homework and Q & A

Lesson 10 from: Developing Android Apps with Java

Tony Hillerson

Homework and Q & A

Lesson 10 from: Developing Android Apps with Java

Tony Hillerson

buy this class

$00

$00
Sale Ends Soon!

starting under

$13/month*

Unlock this classplus 2200+ more >

Lesson Info

10. Homework and Q & A

Lessons

Class Trailer

Day 1

1

Overview: What is Android?

19:56
2

Eclipse and SDK setup and build a Red Flashlight app

38:05
3

Ad a button to a Green Flashlight

21:06
4

Add the Green Flashlight

18:48

Day 2

5

Week 1 - Layout and Build a Task Manager App

04:10
6

Displaying a list of tasks

40:44

Lesson Info

Homework and Q & A

today we set up a and extended our own android application. Um, that extends the the android application that you already sort of invisibly have with your application, and we're gonna share some data there. We used a relatively out for the first time, and we build a form that uses a text watcher to splay on alert dialogue. If there had been in each any meaningful changes since since the since the addition from the audience to the editor X component that we have now, Um, as you noticed, when we close thing, when we close the application, we lost everything we had in memory. All the tasks that we have in a later addition in the later class, I think one or two weeks forward, we're gonna actually store those tasks in a local data base. But if you'd like And don't worry, what was that will pose us on the forms to, But if you'd like, here's some homework that you could do to try to Teoh fix that problem. Ah, in a slightly different and easier way, which is by using the shared preferences ap ...

I So if you go to this link here, developer Andrew dot com reference. Ah, Android content shared preferences html Utkan Learn more about the shared preferences. AP I but basically what you want to do is on add task may be safe like a common delimited list of all the tasks that air that are set up so far. And then in the task manager application on create, which is the first thing is gonna happen in your application. You will pull those out of shared preferences and split him on the comma and then making new tasks out of him. And that's one way that you could do some simple persistence locally, which is probably good enough for this application. But we also are going to do it more, more robust solution with a local sequel, that database later on, Like we say and then down, there is some sample code that you'll probably use end up using something that looks like that in your code. Anyhow, next week we're going to be making a much better looking list, which actually uses an android list component and allows you to check off and complete certain tasks instead of just are simple, bulleted text view that we have right now. so tune in next week and will be going over that all right. And and like you said, we will post the homework in the forum. So if people want to do the homework, you'll be able to access everything, and we'll also send it out an email. So All right, so people are asking to look at that code, which you have up. Um, and I have a bunch of questions, and I'm sure the chat room does to one of the questions that I have. Let me see if I can find it here. Um, somebody asked about the unsafe changes, dialogue, Um, something about why is it dynamic instead of static? And I'm not exactly sure what they mean. I think maybe they're asking why you're creating a new alert dialogue every time rather than building it once. And then we using it. Maybe so. Basically, yeah, I could I could I could create once instead of creating at each time. Um, but the difference is ah, well, a point that may make a difference to use that if I go back to the view, test activity and come back to this ad task activity, it's a completely new activity. So unless I was gonna I mean, definitely it's a valid question. Yeah, you could create it once as a field instead of a local variable here and not go through the whole builder step every time. Um, but in this case, also, I guess another good point is that I'm only creating the alert dialogue if we need to. So you're not You're not taking that hit up front, right? Another example of good lazy loading there. Somebody asked about converting from android 1.62 Google ap, eyes 1.6. Is that a matter of just setting that option? Or do you have to do something else specific? Um, yes. You have to do some other specific stuff once you start using the Google AP eyes, and that has to do with the manifest. Um ah. And we will definitely go over that in a later class but kind of preview. Ah, I don't have the code in front of me, so I'm not quite sure what it is off the top of my head. But you have to in the manifest Say, um which Google Ap eyes that you're using, um, like it s so if you try to use the maps without without telling them Ah, android, that you're using the Google Ap eyes. You'll have some weird errors. OK, but if you if you're not using any of the Google AP eyes and you just wanted to indicate that you planned on doing it, you could Yeah. Then you're you're fine. You don't. There's not a different SDK version for those that's it. Sort of set up to be whatever sdk version, plus some other some other libraries. Um, And then one quick question about the code specific to changes pending. Somebody at pointed out that you might need to cook clear changes pending if the user cancels in case it was set before our welds. Yeah, it's It's a new activity every time. So I don't need to, but But that's a good catch. That's a good good, good, good thought. But I won't need to, because the activity will be new and fresh every time I come back to that. To that view. All right. Um, Sarah and Ruth, do we have any other questions from the chat room? Um, well, I had a question as to where you might find documentation on the XML tags available for layout management. Ah, those are They sit alongside the Java documentation in the the link that we have up on the forums for just Thea. I think it's called reference. So there's a link at the forms for that. Yeah, but it was so It's kind of weird. They don't sweat out the XML from the Java classes basically because in a lot of cases, the XML references a Java class that you can also use. So I could, for instance, there is a job, A class called text for you. Um, so I think the way it does it, um, I don't know if there's been any changes since the last time I looked, but you could go look up the text of you Java class and you can also, I think, on the same view, see all the XML attributes that you might set up. And there was also a question. I don't know if you're gonna be able to pick up the context of this, but there was a question. How do we decide on which layout to use? Um, I think that it's context based, like how How How strange is your layout? Like, um, I'm trying to just think yet here, if it pull up this, like this is definitely it doesn't seem like it's that weird. But it is weird that I want this component to stretch between these other two components or were at least weird enough that I can't use the win your layout. I end up. I've kind of made a decision for myself that I I start with the, uh, the relatively out these days just because I I usually end up there sooner or later. There are a few other choices and more complex layouts. One is called. Ah, actually, I think there was an absolutely out that is no longer there. And there, um, is a frame layout, which is something like, um if you want to have, like, a slide show of components like moving in and out from behind each other so that you just have one in the front. Um, that's that's something you could do for that kind of, ah, of a case, but relatively out. I use most often nowadays because it gives me the power that I want later on. So someone has a question on the emulator. They've got their app compiled and installed, and they want to know how to run it. So maybe you could walk them through that again the first time. I can't use this Run as, um, button up here. The big fat play button. Um, unless I go in and to into run configurations and I could set something up there, I could show you that screen now. But I usually don't set things up this way because it's easier. Um, Teoh just go in and right click the project and save run as, ah Android application. So right, click the project run ass Android application. Um, but if in the run configurations you can you can set things like the target. So I only have one, um, Android Virtual device set up with 1.6. Install it on the google ap eyes installed. Um, but if I have my device plugged in, Andhra device plugged in, then I could set this configuration to manual, and then you could switch between deploying to the emulator or the device so you get more options inside of here, but for the simplest flow, you just right click the project save run as Android application. And then after that, you can go up and select this from the big play button. And I had another emulator question. Somebody eyes seeing the old emulator. And I think I recall you showed briefly how to see the different, uh, the 2.1 emulator one point. So if I come appear and click this sort of device looking thing the android sdk and AIVD Manager, you can set up different virtual devices. Um, two different platforms. Ah, I assumed that they set up the 1. platform because that will show the world red one gold red emulator. Not that 1.6 on above will show this for you. What we see here and by the way, I let me clarify something to on a block post. I don't remember who put it up, but somebody said that I recommend building toe 1.5. Um, just to clarify, I don't I recommend building to 1.5 if you want the furthest reach, because that's gonna be the most commonly accessible installed platform out there. So people have 1.6. You should be ableto as long as you don't use any 1.6 specific things, you should be able to run on 1.5. So that's that's all I meant there to kind of clarify that. I'm not saying that everybody should build against 1.5 like figure out what your situation is. But at least through this Ah, aivd manager, you can set up a 1.5 and 1.6 and a 2.1 and whatever you want and tested all those different platforms from here. Um, And then another question I had was is our global to all the views. Um, it's a class, um, that has all of your all of your view. All of your resource is compiled into it. Is that what you're asking? But you don't have to do anything special for to be able to access it in any of the activities or any of the things that you're any of the other classes that you're using other than well, you do have toe import it. Unless so this That's just a Java rule. Um, I have my our ends up in combat. O'Reilly not Android a task manager. So I don't have to import it to use it in here. But if in different files in a different class, I would need to import it to use it. So it's just a regular job class in that respect. Ah, one thing that I forgot to go through and I will talk about now is noticed this online in set negative button in the ad task activity. I use a android resource. So a resource that comes along with the android, um STK that's provided on the phone. The framework that's actually installed to the phone that has some resource is too. So I can go android that are. That's all I need to do to import that, that our class and then get it. Get access to a string called Cancel, which is, um, already set up by Android. That so that's that's another little trick there they're already some resource is set up by Android, accessible through android that are, I guess I just forgot to show that. But also that shows that it's just a regular job class that you have to use the normal Java rules to get access to. Okay is their list of android recess resource is that are available? Ah, yeah, an eclipse you can go dot and looking. Um, but I think there is, um, there is a list somewhere in the android documentation, but it's a little obscure. Um, but again, I always encourage going to look at the source. So if you check out the android actual framework, um, and go poking around in there, you'll find some interesting things. I don't know if there's a list of global resource is or not, but it may be in one of those one of those links that we have upon the forums. I could look into that. Thank you so much for coming and thank you, Tony. Um, and we'll see you on the forums and on Twitter with android java. And let's give Toni around talking around the boys

Ratings and Reviews

a Creativelive Student
 

I thought everything on this site was free and now they want 99 dollars for a course

a Creativelive Student
 

very good

Student Work

RELATED ARTICLES

RELATED ARTICLES