我有一个带有数字列表的微调器“光圈”,以及一个带有两个选项的微调器“模式”。当按下按钮时,我需要使用各种输入进行计算,包括来自“光圈”的当前选择和从“模式”派生的值。如何调用微调器的值以便在计算中使用它?
另外,在计算中实施之前,如何使用微调器'模式的选择来设置这个其他值?更具体地说,如果微调器设置为小,那么我在计算中使用的值是 0.015,而如果选择大,我需要使用 0.028
我的其他输入是 EditText 视图,所以现在我的设置如下:
input = (EditText) findViewById(R.id.input1);
input2 = (EditText) findViewById(R.id.input2);
input3 = (EditText) findViewById(R.id.input3);
input4 = (EditText) findViewById(R.id.input4);
output = (TextView) findViewById(R.id.result);
output2 = (TextView) findViewById(R.id.result2);
//aperture dropdown
Spinner s = (Spinner) findViewById(R.id.apt);
ArrayAdapter adapter2 = ArrayAdapter.createFromResource( this, R.array.apertures,
android.R.layout.simple_spinner_item);
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter2);
//button
final Button button = (Button) findViewById(R.id.calculate);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
doCalculation();
}
});
}
private void doCalculation() {
// Get entered input value
String strValue = input.getText().toString();
String strValue2 = input2.getText().toString();
String strValue3 = input3.getText().toString();
String strValue4 = input4.getText().toString();
// Perform a hard-coded calculation
double imperial1 = (Double.parseDouble(strValue3) + (Double.parseDouble(strValue4) / 12));
double number = Integer.parseInt(strValue) * 2;
double number2 = ((number / 20) + 3) / Integer.parseInt(strValue2);
// Update the UI with the result
output.setText("Result: "+ number);
output2.setText("Result2: "+ imperial1);
}
}
这不是实际的方程式,它只是一个测试,以确保一切都正确连接。我如何称呼微调器“光圈”和小/大微调器“模式”的值