For my U and I project, I wanted to do something that would be useful to me. My first thought was to flesh out the 7 Wonders scoring app we had worked on in class, but there are already 7 Wonders scoring apps on Google Play (they’re just not very good). Instead, I decided to look at another game that has a complex scoring system: Eclipse: New Dawn for the Galaxy. This is a relatively new game and doesn’t have the recognition in the board game community that 7 Wonders does, so there isn’t an app available.
In my application, I wanted the user to be able to select the number of players in the game. The application would then generate a list of the players and their scores (initialized as “Player 1” with a score of 0). I then wanted the user to be able to click on a player, taking him to a page where he can enter the various things needed to calculate the final score.
To do what I wanted in the MainActivity was pretty easy. I used a TextView and NumberPicker to ask the user how many players there are, and a Button to submit that to the next activity.
To list the players and their scores I extended ListActivity and created a custom layout with two TextView widgets, one for the player’s name and one for the player’s score. When the user clicks on an item it brings up the next activity, expecting a result to come back to it.
Finally, I was able to allow the user to enter values for the various items to calculate the score. Because there are so many of them and I wanted to user NumberPicker to select the values, I had to embed the entire layout in a ScrollView. I hadn’t used ScrollView before, but after I figured out that’s what I needed, it wasn’t hard to implement at all. For the underlying layout, I used a LinearLayout with TextViews, an EditText (for the player’s name), and NumberPickers. At the end of the layout (seen partially above), I wanted to ask a yes or no question, use a CheckBox to record the answer, and have the question’s TextView and CheckBox next to each other horizontally. To do this I embedded another LinearLayout in my vertical LinearLayout, which worked well. Finally, at the very end of the layout I had a button that, when clicked, would calculate the score from the values given above and return to the list of players. I also made sure the back button did the same thing in case the user accidentally hit that instead.
To do most of the passing back and forth of data, I had to really become used to using Intents and Extras. However, once I did one and really understood what was happening, the rest wasn’t bad. Another thing that held me up was the ArrayAdapter for the ListView, but again, once I reviewed our class work and videos, it really wasn’t too bad.
If anyone wants to look at the code, I have it all in a Mercurial repo on Bitbucket: https://bitbucket.org/tboettcher/cs491.u_and_i