Alright so I am fairly new to android app development. I guess you could also say coding in general. I am only familiar with Visual Basic and some HTML/CSS. I am using eclipse and developing in android 1.5
EditText costofmeal, tippercent;
TextView tiptotal;
Button calctipbtn;
BigDecimal costNum, percentNum;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
calctipbtn = (Button) findViewById(R.id.calctipbtn);
costofmeal = (EditText) findViewById(R.id.CostofMeal);
tippercent = (EditText) findViewById(R.id.PercentTipText);
tiptotal = (TextView) findViewById(R.id.tiptotal);
calctipbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
costNum = new BigDecimal(costofmeal.getText().toString());
percentNum = new BigDecimal(tippercent.getText().toString());
tiptotal.setText(costofmeal.multiply(tippercent).toString());
}
});
}
What I want to do is to have tiptotal represent costofmeal * tippercent after calctipbtn is pushed. I have looked at tutorials and other things I just cant seem to get it to work the only error I am getting right now is
The Method muliply(EditText) is undefined for the type EditText
any help sorry if this has been asked before I looked around and couldn’t find something that I understood maybe it had been asked before but I only saw examples that dealt with when they declared and integer and put the variables in. Just not sure how to do it in this case.
thanks
I think you just use the wrong variables :
costNum and percentNum are the are Number while costofmeal and tippercent are texts, so you can’t multiply them.