Discussion on:

Message 3 of 5
0 Votes
+ -
Using an emulator to test with.
While I agree it doesn't work properly on an emulator, I did find it difficult to even compile & build at first. What you might want to mention is to make sure all your Android SDKs (especially the 4.0 and above versions) are up to date. I had an early version of the 4.0 build, and as such the compiler wouldn't recognize R.layout.main , R.id.next , and R.id.previous as valid values. When I installed the updates to 4.0 and 4.0.3. it would recognized them. Note the current update for 4.0 is missing a kernal file, but 4.0.3 works (API 15).
You have your class as Main, yet when I try to run this way, the program just crashes with Class Not Found: com.authorwjf.calsample.CalendarContractActivity
This can be easily fixed simply my renaming the class as CalendarContractActivity (as well as the java file name). Again this just makes it runnable. The Prev and Next button will do nothing and the date will stay in January of 1969, probably due to reasons you mentioned in your article.
You also have the @Override annotation for the <nClick(View v) routine. Eclipse says not to as you only add it when you are overriding a superclass method. So just remove the annotation for the routine.
Also running it the first time may result in failure. If this happens, just close the emulator and try running it again. Something about initial setup I think is causing the install to fail.
Posted by btmaster1
Updated - 5th Jan 2012