tags:

views:

6

answers:

0

i would like to create Android Converter application. Time , Area , Length , Temperature , etc.

I have designed the UI for it. Two Spinner for Selecting the From and To conversion. Two TextBox for displaying Input and Result. 10 number buttons , "." , "Del" , "C" buttons

EX: Both the spinner consist the following items in list.

"Millisecond , Second , Minute , Hour , Day , Week , Year."

Result for Convert Millisecond to Second

Input : 1 ms Output: 0.001 sec

Result for Convert Second to Day

*Input : 86400 sec Output: 1 Day *

Like wish i want to change form any form to any form. Can u plz help me in designing the code implementation. How to design the formulas.

I didnt ask for formulas., i asked for how to apply the correct formula for that conversion.

I will get Id for the Both the spinners.

0 for Millisecond , 1 for Second , 2 for Minute , 3 for Hour , 4 for Day , 5 for Week , 6 for Year.

private void cal(long seconds) {

switch (spinner1.getSelectedItemPosition()) { case 0:
ConvertTo.setText(String.valueOf(seconds * 1000)); break; case 1:
ConvertTo.setText(String.valueOf(seconds)); break; case 2: ConvertTo.setText(String.valueOf((seconds * 60 ) )); break; case 3: ConvertTo.setText(String.valueOf((seconds * 60 * 60 ) )); break; case 4: ConvertTo.setText(String.valueOf((seconds * 60 * 60 * 24) )); break; case 5: ConvertTo.setText(String.valueOf((seconds * 60 * 60 * 24 * 7) )); break; case 6: ConvertTo.setText(String.valueOf((seconds * 60 * 60 * 24 * 7 * 365) )); break; } }

can any one plz post sample code how to design this.