Some simple considerations:
I created a new property that will be used to define text size.
To define a color for the background, I added an entry of type color in string.xml. Something like that:
<color name="red">#900</color>Some notes about menu item.
In order to create menu items, you have to add it in the activity xml. This xml is organized in <menu>, <item> and <group> elements (see doc). Eclipse has a visual editor that helps you in the task.
Adding an item to the menu is as simple as adding an <item> element.
The attributes of the tag are
To attach the menu to the activity, this code is required:android:idA resource ID that's unique to the item, which allows the application can recognize the item when the user selects it.
android:iconA reference to a drawable to use as the item's icon.
android:titleA reference to a string to use as the item's title.
android:showAsActionSpecifies when and how this item should appear as an action item in the action bar.
public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.example_menu, menu); return true; }where example_menu is the name of the xml under res/menu which represents the menu.
In order to open a new activity clicking on a menu item, two methods like these are needed:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.about:
openAbout();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void openAbout() {
Intent intent = new Intent(this, AboutActivity.class);
startActivity(intent);
}
where AboutActivity is a new Activity with some content.