martedì 29 ottobre 2013

01 - Hello Android

I will create a simple hello-something app.
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
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.
To attach the menu to the activity, this code is required:

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.

lunedì 21 ottobre 2013

Some little issues with dependencies

I created a new project in eclipse and shared with egit in order to publish it on bitbucket.
This messed up the project build path a little. It complained it cannot resolve android-support-v4.jar dependency. So I removed the broken dependency from the build path and re-imported it as simple jar (which is by default included in the lib directory).

52 apps in 52 weeks

I want to learn to develop android applications.
This is just a little blog to track my attempt to build an android app every week, hopely learning something in the process :)
If I can stick to the plan, an year from now I would have built 52 apps...