私は本当に NOOB で、新しいコーダーです。Java の学習を開始し、最近このアプリケーションを Eclipse で作成しました。ドルからユーロへのコンバーターです。Eclipse でコードを実行しようとするたびに、アプリケーションが動作を停止したというエラーが表示されます。
TextView dollars;
TextView euros;
RadioButton dtoe;
RadioButton etod;
Button calculate;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dollars = (TextView)this.findViewById(R.id.dollars);
euros = (TextView)this.findViewById(R.id.euros);
dtoe = (RadioButton)this.findViewById(R.id.dtoe);
etod = (RadioButton)this.findViewById(R.id.euros);
calculate = (Button)this.findViewById(R.id.calculate);
calculate.setOnClickListener(this);
}
public void onClick(View v) {
if (dtoe.isChecked()){
convertDollarsToEuros();
}
if (etod.isChecked()){
convertEurosToDollars();
}
}
protected void convertDollarsToEuros(){
double val = Double.parseDouble(dollars.getText().toString());
euros.setText(Double.toString(val*0.67));
}
protected void convertEurosToDollars(){
double val = Double.parseDouble(euros.getText().toString());
dollars.setText(Double.toString(val*0.67));
}
}