Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Android EMI Calculator




Download Project here||Download App here

Another basic application with learning objectives as follows

1. Implementing Reset


Intent refresh = new Intent(this, EMICalculator.class);
startActivity(refresh);
this.finish();

Reset basically means resetting all the fields and getting them back to their original state. In this particular Code I am implementing reset by closing the current Activity and starting it as a fresh activity again.

2. Implementing Menus

Menus can be implemented by adding and xml file in the and inflating it in an activity, we will see this method in some later Application. In this application menus are inflated through the code itself.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add("About").setIcon(R.drawable.about);
menu.add("Exit").setIcon(R.drawable.exit);
return super.onCreateOptionsMenu(menu);
}

3. Handling Menu click

Menu clicks are handelled in a method called onOptionsItemSelected
if(item.getTitle().equals("About")&&item.getTitle()=="About")
{
Intent i=new Intent(this,About.class);
this.finish();
startActivityForResult(i,0);
}

In this particular piece of code ABOUT menu is clicked, by using equals method its verified that which item is clicked then the a fresh activity is started using an intent. Remember when ever you start a new activity always close the current one. Android apps have to run on phone with limited resources, so an activity should not be left open running behind the scene as it will consume valuable resources of the phone.

4. Implementing Image button

imagebutton id="@+id/home" src="@drawable/home" layout_width="wrap_content" layout_height="wrap_content" clickable="true" onclick="myClickHandler"

One more thing that is used in this code although not from android but java is good to mention. I have used number formatter in order to display the results in a desired format.

NumberFormat formatter = new DecimalFormat("#0.00#");

Download Project here||Download App here||Follow @bilal_speed



This post first appeared on Handsome Android, please read the originial post: here

Share the post

Android EMI Calculator

×

Subscribe to Handsome Android

Get updates delivered right to your inbox!

Thank you for your subscription

×