In this PA, you should build off of the ThemeXML app that you should have already written (or, if you are reading this before the due date, you might not have finished yet). The application should be a themed application, continuing with the same theme you chose on the last PA. You should name the project ThemeNav, and you can copy over content from ThemeXML if you’d like.
You should add two buttons to the main Activity from ThemeXML.
Each button should bring the user to new Activity pages, with content on them to view.
Each of the other two pages should display a sequence of content via a ListView
.
The content displayed on those pages should be somehow associated with the theme of the application.
In addition to the rules from the previous PA, here are the updated requirements:
The app should have at least three classes that extend AppCompatActivity
.
One of them should be the main screen of the application, and the other two should be ones that can be navigated to by a button press.
Of the two non-main-page Activities, one of them should display text content in a ListView, and the other should display image and text pairs via a ListView. The strings and images should not be gibberish - they should pertain to the theme of your application. On each page, there should be enough content such that the content is scrollable, even on a high-res phone screen. There should be at least 10 strings on the page with text content, and at least 4 text/image pairs on the image scroll view. You do not need to use a ScrollView with a ListView. A ListView will add scrolling functionality if there is more content than can be displayed in the allowable area.
All resources, including colors, strings, images, should be externalized. When used elsewhere, they should be references by their IDs.
The color of the buttons should be customized to fit the theme of the application.
Shown below is an example of such an application. The theme of the one shown below is the Phoenix Suns, as was the case for the Theme Code/XML application.
Notice several other things, that you should implement in your application:
styles.xml
file and colors.xml
file.android:label
attribute in the manifest file.Below is my recommended development strategy:
Start by adding one button to the XML layout for the main Activity.
You can use the Button
XML tag for it.
When that button is pressed, the Application should display another activity, which will eventually have a list of string content.
Thus, you should create another Activity in your project to do this!
Right click on the app
directory of your project, navigate to “New” -> “Activity” -> “Empty Activity”.
Give the Activity class a name (which should end in “Activity”).
An activity class and a new activity layout xml file should be generated.
You can read these docs to see how to have a button perform an action when pressed.
In order for the button to activate an activity, you can use an intent, like so:
Intent intent = new Intent(this, YourActivity.class);
startActivity(intent);
Work on this until you can get the button to display the new activity.
The next step is to actually get a list of text content displaying in the other activity. You should do this using a ListView with an ArrayAdapter. To use an array adapter
findViewById
method to get the ListView, which should be specified via XML.ArrayAdapter
, passing the list of strings as an argument, along with other arguments.ListView
setAdapter
method to set the adapter for the list view.Create another button and activity similar to how you did in part 1.
When displayed on the screen, the activity should display a list with both images and text, rather than just text.
You should use a SimpleAdapter
with HashMap to get that working.
You can reference the slides for how to accomplish that.
Make edits to the manifest files, colors.xml
, and styles.xml
, in order to update the action bar appropriately.
Ensure it is updated for each activity.
Update AndroidManafest.xml
to specify that the MainActivity
should be the parent of the two other activities you created.
Target platform requirements are the same as for PA 1. As a reminder, you should target:
This PA is due on Friday, September 11, 2020, before 7pm. You should turn it in on Gradescope.
To submit, please do the following:
ThemeNav.zip
.Note that there are not automated tests for this PA, so please ensure that your app works how the specification says it should!