I never realized just how much goes into an app before trying to learn how to make one work! At the same time, I never realized how simple the individual pieces of the app can be.
Here is another app that I made for the course:
https://www.mediafire.com/download/npzaxxd0p0qzfw1
What I have been coming to understand is that looking at an app is a lot like building a puzzle. At first, you dump all of the pieces out of the box, and it looks overwhelming! Obviously, the scope of the app is similar to the size of the puzzle. If it has hundreds or thousands of pieces, it just seems impossible to put it together. But, as I learn more about making apps, I have come to realize that it is simpler if you break your puzzle down into groups, and then focus on one piece at a time.
For instance, if you sort your puzzle out by edge pieces, and put those together, then you can group center pieces by colors or objects from the box, and by working on just one area or group, you can get it done! You don’t have to figure out every piece at the beginning, you can instead focus on just one set of pieces, and everything will eventually hook together.
Similarly, with this currency converter app, I managed (after Googling) to take a number, and multiply it by another number from the user, and present it in a toast, per the instructions. I looked at the numbers, however, and realized that I didn’t want six+ decimal places, just 2. So, one piece at a time, back to Google, and now, praise God, it’s working!
You can check out the code here:
Here is my ANDROIDMANIFEST.XML
[CODE]
[/CODE]
Then my MAIN.XML
[CODE]
[/CODE]
Finally, my MAINACTIVITY.JAVA
[CODE]
package com.mycompany.ustoau;
import android.app.*;
import android.os.*;
import android.app.*;
import android.os.*;
import android.view.*;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.*;
import java.text.DecimalFormat;
public class MainActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void convert (View view){
DecimalFormat precision = new DecimalFormat(“0.00”);
EditText usDollar = (EditText) findViewById(R.id.myDollar);
Double valueUs = Double.parseDouble(usDollar.getText().toString());
Double valueAu = 1.35;
Double calculatedValue = valueUs*valueAu;
Toast toast = Toast.makeText(getApplicationContext(), “You have: $” + precision.format(calculatedValue), Toast.LENGTH_LONG);
toast.show();
}
}
[/CODE]