6 組の編集テキストがあります。すべてを編集する必要はありませんが、少なくとも 1 組は編集する必要があります。私がやりたいことは、空のものをゼロに設定して数学がうまくいくようにすることですが、編集テキストに0が表示されないため、ユーザーはゼロを削除し続ける必要はありません
私が今持っているものは理想的ではありません
if (width1.getText().toString().equals("")
|| height1.getText().toString().equals("")
|| width2.getText().toString().equals("")
|| height2.getText().toString().equals("")
|| width3.getText().toString().equals("")
|| height3.getText().toString().equals("")
|| width4.getText().toString().equals("")
|| height4.getText().toString().equals("")
|| width5.getText().toString().equals("")
|| height5.getText().toString().equals("")
|| width6.getText().toString().equals("")
|| height6.getText().toString().equals("")) {
width1.setText("0");
width2.setText("0");
width3.setText("0");
width4.setText("0");
width5.setText("0");
width6.setText("0");
height1.setText("0");
height2.setText("0");
height3.setText("0");
height4.setText("0");
height5.setText("0");
height6.setText("0");
}
calc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (width1.getText().toString().equals("0")
|| height1.getText().toString().equals("0")) {
Toast msg = Toast.makeText(getBaseContext(),
"Please enter measurements", Toast.LENGTH_LONG);
msg.show();
}
else {
Intent sender = getIntent();
int result100 = sender.getExtras().getInt("Result100");
int result215 = sender.getExtras().getInt("Result215");
int result325 = sender.getExtras().getInt("Result315");
a = Double.parseDouble(width1.getText().toString());
b = Double.parseDouble(height1.getText().toString());
c = Double.parseDouble(width2.getText().toString());
d = Double.parseDouble(height2.getText().toString());
e = Double.parseDouble(width3.getText().toString());
f = Double.parseDouble(height3.getText().toString());
u = Double.parseDouble(width4.getText().toString());
v = Double.parseDouble(height4.getText().toString());
w = Double.parseDouble(width5.getText().toString());
x = Double.parseDouble(height5.getText().toString());
y = Double.parseDouble(width6.getText().toString());
z = Double.parseDouble(height6.getText().toString());
if (getIntent().hasExtra("Result100")) {
total = (result100) - (a * b) + (c * d) + (e * f)
+ (u * v) + (w * x) + (y * z) * 60;
} else if (getIntent().hasExtra("Result215")) {
total = (result215) - (a * b) + (c * d) + (e * f)
+ (u * v) + (w * x) + (y * z) * 120;
} else if (getIntent().hasExtra("Result315")) {
total = (result325) - (a * b) + (c * d) + (e * f)
+ (u * v) + (w * x) + (y * z) * 180;
}
Intent intent = new Intent(MinusOpes.this,
Wl2Amounts.class);
intent.putExtra("Result", total);
startActivity(intent);
}