0% found this document useful (0 votes)
11 views3 pages

Konversimatauang

Uploaded by

Rahma Upin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

Konversimatauang

Uploaded by

Rahma Upin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

<?xml version="1.0" encoding="utf-8"?

>
<RelativeLayout
android:id="@+id/widget33"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="@+id/convert"
android:layout_width="313px"
android:layout_height="45px"
android:text="Convers"
android:textStyle="bold"
android:layout_below="@+id/widget38"
android:layout_centerHorizontal="true" />
<LinearLayout
android:id="@+id/widget38"
android:layout_width="320px"
android:layout_height="217px"
android:orientation="vertical"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true">
<TextView
android:id="@+id/widget39"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dollar"
android:textStyle="bold" />
<EditText
android:id="@+id/dollar"
android:layout_width="123px"
android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="@+id/widget40"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rupiah"
android:textStyle="bold" />
<EditText
android:id="@+id/rupiah"
android:layout_width="119px"
android:layout_height="wrap_content"
android:textSize="18sp" />
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
android:orientation="vertical"
>
<RadioButton
android:id="@+id/dtor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dollar ke Rupiah" />
<RadioButton
android:id="@+id/rtod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rupiah Ke Dollar" />
</RadioGroup>
</LinearLayout>
</RelativeLayout>

package com.example.upin.konversimatauang;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener {


TextView dollars;
TextView rupiah;
RadioButton dtor;
RadioButton rtod;
Button convert;

/** Called when the activity is first created. */


@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);

dollars = (TextView)this.findViewById(R.id.dollar);
rupiah = (TextView)this.findViewById(R.id.rupiah);

dtor = (RadioButton)this.findViewById(R.id.dtor);

rtod = (RadioButton)this.findViewById(R.id.rtod);

convert = (Button)this.findViewById(R.id.convert);
convert.setOnClickListener(this);
}

public void onClick(View v){


if(dtor.isChecked()){
convertDollarsToRupiah();
}
if(rtod.isChecked()){
convertRupiahToDollars();
}
}

protected void convertDollarsToRupiah(){


double val = Double.parseDouble(dollars.getText().toString());
rupiah.setText(Double.toString(val*12000));
}
protected void convertRupiahToDollars(){
double val = Double.parseDouble(rupiah.getText().toString());
dollars.setText(Double.toString(val/12000));
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy