Saturday, July 26, 2014

Day 3: TextViews and Spinners

Day 3: It's slowly coming together, the chronometer is done, and now it's onto the textViews and spinners. When I first heard the word "spinner" in an Android context, I thought, "Oh, the spinny wheel when things load?" Nope, not even close. A spinner is actually a drop down menu of options to choose from. 

First things first, let's tackle the easy things: textViews. TextViews are easily generated by loading up the XML file  associated with the Activity and in the graphical view, dragging the TextView onto the screen. To edit this, simply head to the XML layout and you can change name, textSize, textStyle, id, and much more! After configuring my textViews, I went on to add the spinner. Like the TextView, simply drag it onto the screen.

Configuring the Spinner is not as simple as a TextView, however. First, create an instance of the spinner similar to Day 1's buttons, instead however, with type Spinner. To add values into a Spinner, one must use an adapter. I found this resource particularly helpful: Android Guide: Spinners. The developer guide goes quite in depth with example code. I simply followed that and was on my way. 

With two things crossed off my list, I decided to have a little fun and put some quotes in the empty space of my application. I knew it would be impossible to display multiple quotes; it simply will not fit unless the font is miniscule. It would be super cool if it could display a different, random quote out of an array of quotes I have, each time the application is opened. Thus began my quest on Google to learn how this would be possible as I had no ideas. I followed this solution on stackOverflow and simply ignored the Button events. This worked perfectly and I now had quotes on the bottom.

Looking good right? 

Thoughts: It's getting closer and closer! I even made a quick icon on Paint today!
What I still need to complete: Chronometer stopping in x minutes as specified by spinner, and notifications when those x minutes are up!

No comments:

Post a Comment