Android: how to multiply values from EditText

androidandroid-edittextandroid-listviewmultiplication

Ok, first thing is that I am new in Android development, please do not shoot me for the question.

So, I am developing an app yhat needs to multiply from 3 EditTexts:

resultsEditText
amountEditText
taxEditText

They are set with the same name in the R.java. what I want is the following:

amountEditText * taxEditText = resultsEditText

I have no idea in how to implement this, I have searched the internet and this site, which I use as a reference for all my Android development needs, and all the code I found doesnt work at all. I dont know what else to do. Thanks in advance!

Best Solution

You need to set EditText input type as number as well so user can input only numbers.

int a = Integer.parseInt(resultsEditText.getText().toString().toTrim());
int b = Integer.parseInt(amountEditText.getText().toString().toTrim());
int c = Integer.parseInt(taxEditText.getText().toString().toTrim());

    int result = a * b * c;