Skip to main content

Wrap up, Homework and Q&A

Lesson 16 from: Developing Android Apps with Java

Tony Hillerson

Wrap up, Homework and Q&A

Lesson 16 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

16. Wrap up, 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

Wrap up, Homework and Q&A

we have created a list of you instead of just that boring text bulleted list thing. We use that android list I D, which automatically was hooked up by the list activity. So we didn't need to do any wiring there. We also use the magic Empty I D, which was automatically managed by the list activity. Then, um, we created a custom list view, which had a check box on the label, and we created an adapter, which extended base adapter and managed the task list that we had. We listen for clicks to the to the list and toggle the completeness of a task based on the click, and we added a remove complete, all removed, all complete tasks button, which removed all the tasks that were in the completed state. Let's get the questions in just a second. Let me kind of give you a heads up on what the homework could be. So just like I said, um, earlier based base adapter is a very dumb class. There's not much implementation in there at all. Um, there's an easier way to do lists when you don't really care to...

o much about controlling much about, um, the adapters implementation. And that is, um, hinted at here in the homework. Um, and that adopter is called an array adaptor. So instead of using that base adapter and implementing a whole bunch of things, we could just simply use a system class called array adaptor, and you can see here what I'm suggesting you do is build a separate project. Um, make yourself a main XML, which contains a list just kind of like we have here in the code and then, um, change that set. So said that listened after Just like we said the list after to the adapter that we created, said the analyst adapter to an array adaptor, which takes a a, um, generic type of string and, um, used this system is android defined android dart at layout layout. Simple list item one, which just displays a simple string and then pass it the array lists of strings. And you can see that there's a much simpler way to do adapters given that you don't need to be too flexible. Um, so I like to I in the code that I created today, I like to push a lot of the the management of the collection of the data into the adapter. So I did some things like toppling the completeness of the of the clicked item and inside the adapter. And so, if you want a little more flexibility, you'd probably have to use a base adapter. But if you don't care about it too much, you can use this array adaptor. And that is a good piece of homework for, um, kind of understanding a bit more about how lists work out there in the wild. And ah, thanks for tuning in. We'll take questions in a second. But next week we're going to be taking the application that we have so far in making its persistent, so that when we if you shut off the power on your phone or reinstall the application during development during a screen cast or something than the the tasks that you added last time, we'll stick around. So that's what we have. Let's take some questions, right? We have quite a few, um, one of the points that somebody on the chat room is making Is that the name for the magic? I DS is the android convention. I d. Does that sound right to you. Is that the official name for them? Ah, I haven't heard that. Which could be I mean, well, that's it's That's kind of how it works, isn't it? I mean, by using that convention, I don't have to tell the list activity. Ah, what lists to use? It just knows how to go into the view that set as the content view on the activity and find the list that it needs to use. Yeah, so it's it's using a convention to do that is related to that is at I d slash android colon list the same thing as at Android Colon. I d slash list. I don't know. OK, let's try. Let's try it and see. Ah, What is it I'm discussing here, Android, If I could spell ah, like this, let's give it a look. No, it is not because it doesn't know what that is. So what he's talking about is ah, um, where was that task list item he's talking about? Is this I think All right. Um and this is I mean, this is I don't know. I can't really say much about this is beyond the scope of our class. This is weird. Um, I kind of know what's going on because I've kicked kicked around in the code, but it's I can't explain to you why you would care about this kind of stuff because it would be used in, like, more complex situations where you wanted to make an application like, kind of dynamically scannable, I guess. And you would define the set of attributes that you would use as, um, here here, the things that you can look up that have names and then the implementation could be different based on things that are defined. Another ex model files elsewhere, But I don't know. We can discuss more about that on the form, because that's just a weird thing. And I found that code somewhere in the android source code for synapse. And that's what I used. So hopefully that's not throwing too many people off, but at least answers that question. Another question I got was is notified. Data set changed a method on the adapter. Yes, So this is implemented on base adapter. It's one of the one of the thin pieces of implementation that base adapter gives you. Okay. And then one last one for me and then I'll hand it over to Sarah and Ruth. I know they're itching to go with questions somebody asked to go if you could do just a really quick review of what the context is again. A context is just like the name means. It's Ah, it's, um, information about the situation into which ah, um, like something new is going to be begin to be used, I guess is a general way of saying it. So every activity extends context up the chain list activity here extends activity, which extends, I think, context at the top. I don't know, I could pull the docks, but I won't waste time on trying to find it right now. If you want to go look at the inheritance chain of activity, it will get you up to a context. And the context has some information that is important for views that are getting created. So generally you'll be passing around a context when you're creating views, because somewhere up the inheritance chain someone needs to know about the context that it's getting. It's getting, um, displayed into Okay, so So it sounds like, really sure what else is on contact. Okay, So it sounds like it's it's, uh the current activity that you're in is the context. Yeah, Yeah, it turns out being the current activity in a lot of cases. But the reason for it is, um, I'm opening up the context class here that I don't have source attached, but it'll maybe show some of the methods that are on it. What? Sounds like a good pull it up. Over. Yeah, it sounds like a good thing to discuss in the forums to Yeah, more details. Um, it's So are these magic quote unquote ideas officially supported by the SDK or they under the hood features that might be subject to removable? Sorry. Removal later in the releases. Um, that's a good question. I, uh I mean, this is the way that android app store built, and I wouldn't really call an android app that is shipped with the with the phone like a private AP. So, like implementation that it uses, I would think, you know, even though Google has special knowledge, whenever they change something about the sdk there, and then they would have to fix all the APS that use that used whatever they fix or deprecate ID. Um, I don't know. I would. My intuition says Don't worry too much about using those things because that's the way the android like, say, your contact manager on your android phone. It's using the same same, I think that I mean, I I think that's like I don't remember what happened. I what haps that I looked at that used this android list thing. But they're all using this. Ah, I d the same way. So, uh, I wouldn't call it private, but that's a good question. That's definitely something. Look into. I have a long question. Someone wrote. I heard and read recently. Got a multi touch update. Now, if I add lots of tasks so that the screen meal status used up and then swipe my finger to scroll, do I need something special to implement that? Or will the Android 80 Tiatto take care of such low level stuff? It's, It'll take our little stuff Well, why don't I want to add a bunch of tasks while we take the next question? We could look at that actually working and then, uh, if you set, add task to fill parent and remove complete to fill parent. Would they be 50% h with padding? Of course. No, it's It's a pain to make things 50% to take up 50% of the screen. Ah, no, they don't magically do that. They Ah, you either get Phil parent or you get wrapped content and wrap content takes it, um, takes his biggest. I mean, it caused the problem that Paul saw earlier that Paul pointed out earlier that task Phil, Parent just fills up the whole thing and doesn't care about what's next to it. So you needed to use another type of layout or you would need Teoh, Or you would need to, like, put exact pixel with which is a bad thing to dio because, um, if you put an exact pixel with and you change the orientation than they wouldn't take up much of the screen, it would kind of look would break your lay out a little bit. Um, and there's, uh it's really kind of a pain to get things toe layout 50% next to each other. I really wish they had percentage. Basically out is the answer to question, but they do not. And here's Here's an example of the list scrolling That's just right out of the box with the list of you does. Okay, then I had a couple of more extraneous questions. I don't even know if they're here. And if we need to post these on the forum, um, the poster agreed to that. That is they're interested in in using auto getters and centers in eclipse. Uh, and you demonstrate that earlier, um, in the class, but by using the fields and they wanted to see a demo of that again because I didn't quite catch that they're not quite to eclipse as others. Yeah, I guess that's in the scope of the class, because I keep talking about that stuff, don't I? So let me go to a simple class and do that really quickly. Let's say we wanted to add a variable. I'm just gonna type it straight through. So I want to add a variable object called food. Now I've added a private variable which is never referenced to the compiler says, Hey, are you sure that you want this thing because it's never referenced? And luckily, because that is never referenced a clip sees that as a warning and gives me this little hover guy so I can come here and say create getter and setter for food and then it will give me this dialog box. But if I cancel out of that, I can always do this by going to source generate getters and centers. And this will allow me to pick any of the any of the fields that I have set up that do not already have a getter and setter So I can pick food and then tell where I wanted Insert it, um, tell the access, modifiers and stuff like that. Click OK, and it generates based on the name food, get fu and set food which takes the type of food and such it to object here. Hopefully everybody caught that and otherwise we'll take it to the forms and that we have an audience member who had some questions about his code. I'm not using quite the same environment that you're using. I'm using Ah, intel Ajay, and it takes a very dim view, although it will accept it and the code seems to work. It takes a very dim view of having checked text view in the XML and I'm wondering if there's some access D which isn't very happy about it. Uh, that definitely could be. Um maybe that is because I don't know. Ah, So why don't we take the next question and come back to this one? Will I look on the docks and see if check text for is actually there in the docks? I have a question. If you have multiple multiple views, how does adapter know to which view? It has to notify which year by position by position. Um Well, okay, I guess that's that's kind of a trade answer. Let's go back. And here's a second. Let me kick this guy off. Yeah, it finds check sexually in the documents. I don't know. It's right there. Um, I'd say the problem is probably to be with the whatever. Ah, I d type set up. You're using an intelligent and he's just using stuff in the command line. Oh, no, it's an I d. It's got its own android. Uh, plug in does does most driving. Maybe you could raise this up as a bug to them. Okay, because I don't see, I don't think there's any problem with it. And android doesn't think there's any problem with it. Okay, so the question was I guess when something is tapped, how does it know what would view to reference about the about the adapter again? If we have multiple views, how does adapter Noto which view it has to notify? Well, I mean, that's why there are these get item I d, um, And the position variables being passed around a lot. So, um, the position I mean, if you think about it, you wouldn't want to do it. Well, I mean, there may be some weird situations where you like you have to manage. You could manage to lists into into one list of you Two lists of data to array lists of data are more or more into one view, I mean, and that's what adapter would be good for. Two. But the position in the overall list. The adapter needs to know how to translate the position because you can see position is an argument here to just about every of these important methods. So it needs to know based on position and even even the methods that I implemented took a position and, ah, figure out which task we're talking about. And it can always get and get a reference to the view by position, given that the view is on the screen. Ah, and actually, really? I mean, get view is the only place that adopter cares about the view to Is another, I guess. Interesting part to the answer. So everything is done by position inside the adapter. I think that is the answer to that question. Okay. And I have one more question. Do you know of a list that you confined somewhere of available android components? Um, yeah, that was asked earlier. Now, I guess it is a fine time. Is any? Well, no, I I kind of pushed it off. I kind of pushed it off to the to the forms or something. But, like, just unless you want to go figure out how to look through the source code, um, which I'm not going to talk about just yet because it's kind of complicated. Um, you need to go to developers at Andrew dot com, which is one of the the reference links that we have upon the forums. That's the documentation for everything. You could go poke around the deaf guide and a lot of things will pop out to you. They're based on more sort of interesting topics, like under user interface, um, building custom components or but binding to data with an adapter view. Ah, those kind of things that will. You'll run into a lot of components that are used in there like, say, for instance, alert dialogue, which is right here. Or you could go to the reference and look down the whole class list because every one of those those ah, like, for instance, here's check text view the one that I used, um, for our little are are each item renderers implements checkable. So it means it has a checked method or a checkmate that I think her set, Schachter said. Checked and get is checked. Um, and then it has its own toggle, which is interesting. Two. Because that's how we implemented task. Um, and it extends text view and which extends view which extends object. I don't know. You could just you could just sort of, ah, look around an android widget package. And here are all the widgets and things that have to do with widgets like adapters and checkable. I guess I mean this without knowing what you want to implement. I couldn't tell you what components are important, but here is a list of all the components, and you can kind of get a good sense of them. And figure out what? Where you could use those in your own applications later. Great. Thank you so much, Tony. I think we're gonna wrap it up because we're already 16 minutes overtime. So thanks everybody for sticking around so long. Um, and we'll give Tony a round of applause and say thank you very much.

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