Skip to main content

@Override can be handy to figure out typing errors


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.

Comments

Popular posts from this blog

How to use JCalendar date picker in your Java Swing Applications with NetBeans

If you are one of those JAVA beginners like me who wants to implement a datepicker module in your experimental/business critical application developed with NetBeans IDE , then this for you. Let me share how I figured out to do so in simple steps with a sample code. Assuming that you have your Java Swing application ready, you will need to download the JCalendar package from here http://www.toedter.com/en/jcalendar/index.html . The page lists out various modules available with descriptions like JDateChooser, JCalendar, JYearChooser, JMonthChooser, JDayChooser, JSpinField and JLocaleChooser. The one I chose for my app was JDateChooser. After downloading and opening the ZIP file, you can see a whole set of files in it. The one we need is in the folder ‘lib’ with the name jcalendar-1.4.jar (this is the latest version while I was writing this). extract that file to your folder of comfort. The jar file you just extracted contains everything you need to implement the date picker in y...

Honda CB Twister India : A Quick Review

I came across a dozen reviews of Honda CB Twister on web and finally decided to buy it. I owned it on last March, 2012. It costed around ₹63,000 with disc brakes, alloy wheels, road tax and stuffs. The reason why I have included ‘India’ in title is because Twister is also available as Honda CB110 in other countries. Here is my short account on my experience with Twister. Mileage Mileage is a very essential part of my riding experience. I travel around 200 Kms every week, so fuel expenses shouldn't make me bankrupt. Twister’s 60 – 65 KmpL mileage is one of the factors that influenced my choice while buying. Anyway in advertisements its claimed to be 70KmpL.   Engine Nowadays its a increasing trend to see Indians going for high end bikes, but in my case I am good with medium performance engines. Twister’s 110CC engine makes riding smooth up to 55Kmph speed, beyond that Honda Twister turns in to a Honda Vibrator. Considering the fact that I’m not an adrenalized rider, ...

How to open a PDF file using ICEpdf Viewer from your Java Application?

Few weeks back I designed an application, where I wanted to display Help content through a PDF file rather than through a textbox in a JPanel, because the help content had complex formula stuffs. So I thought of embedding the PDF file with my swing application itself. But it was too tricky to learn in a short span of time. So I figured out two options to display the help content. By opening the PDF file using a native PDF Reader in the system, on click of the Help Button in my Java Swing application. By opening the PDF file using a PDF reader integrated with my application jar package, on click of the Help Button in my Java Swing application. I dont want to discourage the readers, but to be frank the above two methods didnt work for one bad reason. You need the absolute path of the PDF file to be used in the source code. One solution would be to load a PDF file from a Web link. Another solution would be to use an installation wizard (See here ) for your Java application to plac...