ToDo List Resources Example

In this example you'll create new external resources in preparation for adding functionality to the ToDo List example you started in Chapter 2. The string and image resources you create here will be used in Chapter 4 when you implement a menu system for the To-Do List application.

The following steps will show you how to create text and icon resources to use for the Add and Remove menu items, and how to create a theme to apply to the application:

1. Create two new PNG images, one to represent adding a to-do list item, and one to represent removing an item. Each image should have dimensions of approximately 16 pixels by 16 pixels, like those illustrated in Figure 3-5.

2. Copy the images into your project's res/drawable-mdpi folder and refresh your project.

3. Open the strings.xml resource from the res/values folder and add values for the add_new, remove, and cancel menu items. (You can remove the default hello string value while you're there.)

<?xml version="1.0" encoding="utf-8"?> <resources>

<string name="app_name">To Do List</string> <string name="add_new">Add New Item</string> <string name="remove">Remove Item</string> <string name="cancel">Cancel</string> </resources>

4. Create a new theme for the application by creating a new styles.xml resource in the res/values folder. Base your theme on the standard Android theme, but set values for a default text size.


<?xml version="1.0" encoding="utf-8"?> <resources>

<style name="ToDoTheme" parent="@android:style/Theme.Black">

<item name="android:textSize">12sp</item> </style> </resources>

5. Apply the theme to your project in the manifest.

<activity android:name=".ToDoList"

android:label="@string/app_name" android:theme="@style/ToDoTheme">

Was this article helpful?

0 0
Mobile Apps Made Easy

Mobile Apps Made Easy

Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.

Get My Free Training Guide

Post a comment