​A currency converter app.

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]

<?xml version=”1.0″ encoding=”utf-8″?>

<manifest xmlns:android=”http://schemas.android.com/apk/res/android&#8221;

    package=”com.mycompany.ustoau” >
    <application

        android:allowBackup=”true”

        android:icon=”@drawable/smallflags”

        android:label=”@string/app_name”

        android:theme=”@style/AppTheme” >

        <activity

            android:name=”.MainActivity”

            android:label=”@string/app_name” >

            <intent-filter>

                <action android:name=”android.intent.action.MAIN” />
                <category android:name=”android.intent.category.LAUNCHER” />

            </intent-filter>

        </activity>

    </application>
</manifest>
[/CODE]
Then my MAIN.XML

[CODE]

<?xml version=”1.0″ encoding=”utf-8″?>

<LinearLayout

xmlns:android=”http://schemas.android.com/apk/res/android&#8221;

android:layout_width=”match_parent”

android:layout_height=”match_parent”

android:background=”#FBFFFF”

android:orientation=”vertical”

android:gravity=”top|center”>
<TextView

android:text=”US to AU currency converter”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:background=”#002AFF”

android:textSize=”30sp”

android:gravity=”center”

android:textColor=”#FFFFFF”

android:id=”@+id/mainTextView1″/>
<ImageView

android:layout_height=”wrap_content”

android:layout_width=”wrap_content”

android:src=”@drawable/flags”

android:id=”@+id/mainImageView1″

android:layout_margin=”20dp”/>
<TextView

android:layout_height=”wrap_content”

android:textAppearance=”?android:attr/textAppearanceMedium”

android:layout_width=”wrap_content”

android:text=”Type in how many American dollars you have and push the converter button to see the value in Austrailian dollars.”

android:gravity=”center”

android:padding=”35dp”

android:id=”@+id/mainTextView2″/>
<EditText

android:layout_height=”wrap_content”

android:inputType=”text”

android:layout_width=”wrap_content”

android:gravity=”center”

android:ems=”10″

android:id=”@+id/myDollar”

android:padding=”10dp”

android:layout_margin=”30dp”

android:background=”#FFFFFF”/>
<Button

android:layout_height=”wrap_content”

android:layout_width=”wrap_content”

android:text=”Convert”

android:id=”@+id/mainButton1″

android:onClick=”convert”/>
<TextView

android:layout_height=”wrap_content”

android:textAppearance=”?android:attr/textAppearanceSmall”

android:layout_width=”wrap_content”

android:text=”This must be a numerical value, or the app will crash. It can have decimal places. Also note that this is based on the echange rate on 20161118.”

android:id=”@+id/myTextView”

android:gravity=”center”/>
</LinearLayout>
[/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]


Linux – keep it simple.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s