As a next step in Android App
Development I leaped from simple layout with text(TextView) that says
“Hello World” to a bit complex layout with Image(ImageView) and
Menu features. It was amazing how everything in Android is coded in
to XML. Java was required only to initiate the entire setup made in
XML.
So the functionality of my app is
simple. Its a layout with a background color and with an image in it.
I had a menu with two options to change the image and one option to
change the background color. The final option is to trigger an dialog
box(AlertDialog) and the dialog box will have a title, message and
two buttons – one for resetting image and other for the background
color.
After completing the coding part, I
compiled and ran the code in emulator. The app opened fine but I was
unable to open the menu when I click menu button. No matter how hard
I blew the menu didn't inflate (The method used to initiate a menu
xml code is called as 'inflate'.) so I guessed that something has
gone wrong with the Menu Launcher code, but I couldn't figure out any
grammatical error. While surfing the web for solution I came across
@Override feature in Java. Though the function of this is to make the
subclass override the superclass, it can be used to highlight typo
errors. In my case I found out the error in onCreateOptionMenu() . I
misspelled 'onCreate' as 'onCraete'. This comes in handy while
programming in Android Platform since most of the class you use are
gonna be the extended versions of predefined super classes.
You can download the app from here https://sites.google.com/site/greengearstech/apps with the title Kronos.
You can download the app from here https://sites.google.com/site/greengearstech/apps with the title Kronos.
Comments
Post a Comment