私は以下に苦労しています。コードは正しいと思いますが、このアクティビティに行くとアプリケーションがクラッシュしますか?
誰かが私を助けて、私が欠けているものを指摘してもらえますか?
import java.text.DecimalFormat;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
public class CanopySizer extends Activity implements RadioGroup.OnCheckedChangeListener{
EditText CanopyLength, CanopyWidth;
TextView Volume;
RadioButton Light, Medium, Heavy;
RadioGroup Loadings;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.canopysizer);
CanopyLength=(EditText)findViewById(R.id.CanopyL);
CanopyWidth=(EditText)findViewById(R.id.CanopyW);
Volume=(TextView)findViewById(R.id.Volume);
Light=(RadioButton)findViewById(R.id.Light);
Medium=(RadioButton)findViewById(R.id.Medium);
Heavy=(RadioButton)findViewById(R.id.Heavy);
Loadings=(RadioGroup)findViewById(R.id.Loading);
Loadings.setOnCheckedChangeListener(this);
}
public void onCheckedChanged(RadioGroup Loadings, int aplication) {
if (aplication==Light.getId()){
double Canopylength = Double.parseDouble(CanopyLength.getText().toString());
double Canopywidth = Double.parseDouble(CanopyWidth.getText().toString());
double CanopyArea = Canopylength * Canopywidth;
double ExtractionRate = CanopyArea * 0.25;
DecimalFormat df = new DecimalFormat();
Volume.setText(df.format(ExtractionRate));
}
if (aplication==Medium.getId()){
double Canopylength = Double.parseDouble(CanopyLength.getText().toString());
double Canopywidth = Double.parseDouble(CanopyWidth.getText().toString());
double CanopyArea = Canopylength * Canopywidth;
double ExtractionRate = CanopyArea * 0.35;
DecimalFormat df = new DecimalFormat();
Volume.setText(df.format(ExtractionRate));
}
if (aplication==Heavy.getId()){
double Canopylength = Double.parseDouble(CanopyLength.getText().toString());
double Canopywidth = Double.parseDouble(CanopyWidth.getText().toString());
double CanopyArea = Canopylength * Canopywidth;
double ExtractionRate = CanopyArea * 0.50;
DecimalFormat df = new DecimalFormat();
Volume.setText(df.format(ExtractionRate));
}
}
}