博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Dollars_Euros
阅读量:2299 次
发布时间:2019-05-09

本文共 1565 字,大约阅读时间需要 5 分钟。

package com.skpack.Dollars_Euros;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 Dollars_EurosActivity extends Activity implements OnClickListener {	/** Called when the activity is first created. */	TextView dollars;	TextView euros;	RadioButton dtoe;	RadioButton etod;	Button convert;	@Override	public void onCreate(Bundle savedInstanceState) {		super.onCreate(savedInstanceState);		setContentView(R.layout.main);		dollars = (TextView) this.findViewById(R.id.dollars);		euros = (TextView) this.findViewById(R.id.euros);		dtoe = (RadioButton) this.findViewById(R.id.dtoe);		dtoe.setChecked(true);		etod = (RadioButton) this.findViewById(R.id.etod);		convert = (Button) this.findViewById(R.id.convert);		convert.setOnClickListener(this);	}		@Override    public void onClick(View v) {        if (dtoe.isChecked()) {            convertDollarsToEuros();        }        if (etod.isChecked()) {            convertEurosToDollars();        }    }       protected void convertDollarsToEuros() {        double val = Double.parseDouble(dollars.getText().toString());        // in a real app, we'd get this off the 'net        euros.setText(Double.toString(val*0.67));    }       protected void convertEurosToDollars() {        double val = Double.parseDouble(euros.getText().toString());        // in a real app, we'd get this off the 'net        dollars.setText(Double.toString(val/0.67));    } 	}

转载地址:http://agzib.baihongyu.com/

你可能感兴趣的文章
各种大佬博客
查看>>
素数筛法
查看>>
SPFA模板
查看>>
统计不同单词个数
查看>>
真假前后缀
查看>>
Manacher马拉车
查看>>
字典树[HDU-1251]
查看>>
回文时间
查看>>
相似三角形
查看>>
2-2 Time类的定义
查看>>
手机键盘
查看>>
计算长方体、四棱锥的表面积和体积
查看>>
欧拉筛(线性o(n))
查看>>
C - Contest Setting Gym - 101982C
查看>>
求组合数
查看>>
B - Assignment HDU - 5289-RMQ
查看>>
数据结构实验之图论十一:AOE网上的关键路径
查看>>
数据结构实验之图论十:判断给定图是否存在合法拓扑序列
查看>>
Java与Python哪个更好?
查看>>
JAVA 实验五 输入输出练习
查看>>