[英]trying to move value from edit text and spinner
I want to get the value from a edit text and values from 3 spinners and calculate the value. 我想从编辑文本中获取值,并从3个微调器中获取值,然后计算值。 Below is the code I have so far, remember that I am beyond new at this.
以下是我到目前为止的代码,请记住,我在这方面并不陌生。 I do not know how to get the value rollPrice to equal B3 in the formula as it gives me an error since rollPrice is put into a string.
我不知道如何将值rollPrice等于公式中的B3,因为因为rollPrice放在字符串中,这给了我一个错误。
**Clarification edit. **说明编辑。 The slength, swidth, and sthick are values selected from spinners.
slength,swidth和sthick是从微调器中选择的值。 the rollPrice is an edit text the user puts the price into and then selects the values from the 3 spinners, and the formula will compute the MSF price.
rollPrice是用户输入价格的编辑文本,然后从3个微调框中选择值,该公式将计算MSF价格。
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
try{
// Change the billBeforeTip to the new input
rollCost = Double.parseDouble(arg0.toString());
}
catch(NumberFormatException e){
rollCost = 0.0;
}
};
private void calculate(){
String B5 = swidth.getSelectedItem().toString();
String B6 = slength.getSelectedItem().toString();
String B4 = sthick.getSelectedItem().toString();
MSF=1000/(Double.parseDouble(B5)/12*Double.parseDouble(B6))*Double.parseDouble(B3);
}
Because you have mentioned that you are using EditTexts. 因为您已经提到过您正在使用EditTexts。 I would suggest you to use (your question is unclear, I have assumed swidth,slength and sthick are edittexts)
我建议您使用(您的问题不清楚,我假设swidth,slength和sthick是edittexts)
String B5 = swidth.getText().toString();
String B6 = slength.getText().toString();
String B4 = sthick.getText().toString();
instead of 代替
String B5 = swidth.getSelectedItem().toString();
String B6 = slength.getSelectedItem().toString();
String B4 = sthick.getSelectedItem().toString();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.