Android resources

Trying out Menus and PreferenceActivity.

Here’s a list of the things that can be represented as resources in Android (docs here are quite helpful – though they don’t mention preferences!):

  • Strings
  • Arrays of strings
  • Views and layouts
  • Menus
  • Preferences
  • Styles/Themes
  • Colors
  • Multimedia (pictures, video, sound)
  • Animations
  • Graphics (Drawables)
  • Search (I have not seen this in a book yet!)
  • AppWidget

And things that can be done by clever use of resources that would otherwise require clumsy code:

  • I18N/L10N
  • different layout for portrait/landscape, or for different screen sizes
  • different resources for different API levels

Preference and Menu resources are pretty simple to work with. I wonder why the first thing everyone goes for is the in-code route? Then you have to create your own constant identifiers for the items, pull string resources into code, and so forth… seems like all the tutorials ought to describe using resources for that. It’s documented in the SDK, it’s just not indicated as the way to do things. Thank you “Hello, Android” for giving me a heads up.

BTW, it would sure be great if the resource builders in the ADT were more aggressive about telling you that you’ve misused the elements. At this point I’m finding out when I deploy the package and navigate to the Activity!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: