我在下面遇到困难。我相信代码是正确的,但是当我进行此活动时,它会导致应用程序崩溃吗?
任何人都可以帮助我并指出我所缺少的吗?
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));
}
}
}