Professional Android 2 Application Development
If you are just looking for a sample, the publishers of Professional Android 2 Application Development have all their example code available for download and there is a compass application in chapter 14.
You need the following
You also need to install the Android ADT on Eclipse , here are the steps:
You can follow the install procedure from the Android SDK page above or from a brief tutorial I wrote at DroolJunkie
Update : You may also use the following screen casts to help with installation (Source/Credits)
As for how to learn to develop on Android you can start by reading artilces and tutorials on developer.android.com and using Stackoverflow and Google. There are also a few good books available. Here are 3 I like:
Pick up a book such as Hello Android. It's an easy read to skim through to pick up the basics of Android. I also bought this book buy Reto Meier.
You can also learn a lot by reading some of the more popular questions on Stackoverflow tagged Android.
Poke around some open source projects. There are some popular ones such as FourSquare that you can look at. Here is a list on Wikipedia.
I also wrote about some of my first experiences on Android here with my open source app.