10 Useful Classes and Interfaces in the Android API - dummies

10 Useful Classes and Interfaces in the Android API

By Barry Burd

As an Android developer, you don’t memorize facts about classes and interfaces in the Android API. Instead, when you write an Android app, you constantly consult Android’s API documentation. But for novice developers, searching Android’s docs can be tricky. You have to know where to look for the classes and interfaces that you need. This list ten good starting points: Android’s most useful classes and interfaces.

  • android.app.Activity: Create a screenful of content as part of your Android app.

  • android.view.View: Any user interface component is a view. Examples include TextView, ImageView, ProgressView, EditText, KeyboardView, CheckBox, Button, and dozens of others.

  • android.view.View.OnClickListener: Respond when the user taps the device’s screen.

  • android.view.MotionEvent: Respond when the user drags, zooms, or pinches on the device’s screen.

  • android.content.Intent: Use an intent to launch a new activity.

  • android.view.animation.Animation: This class is the starting point for Android’s View Animation framework. Make items move, rotate and do other cool things on the device’s screen.

  • android.animation.Animator: This class is the starting point for Android’s Property Animation framework. Programming property animation is more complicated than programming view animation. But property animation offers many more options than view animation.

  • java.text.NumberFormat: Make numbers look good on the user’s screen.

  • java.lang.String: Do everything you ever want to do with strings of characters: find characters, find substrings, replace substrings, make uppercase, make lowercase, trim away blank spaces, paste strings together, and much more.

  • java.lang.Math: Do you have any numbers to crunch? Do you have to position an avatar on the screen? If so, try Java’s Math class. (It’s a piece of code, not a place to sit down and listen to lectures about algebra.) The Math class deals with pi, e, logarithms, trig functions, square roots, and all those other mathematical things that give most people the creeps.