Не знаю, как получить результат от цена и процентов чтобы показать цену после скидки!Код для расчета процентного нерабочего
// write the percentage
final EditText editPrice = (EditText) findViewById(R.id.editPrice);
// write the price
final EditText ePercent = (EditText) findViewById(R.id.ePercent);
// Hopefully to get the result
final TextView result = (TextView) findViewById(R.id.viewResult);
Button buttonConvert = (Button) findViewById(R.id.buttonConvert);
buttonConvert.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
try {
double price = Double.valueOf(editPrice.getText()
.toString());
// percent
double per = (price/100.0f) * ePercent;;
result.setText(String.valueOf(per));
Любая помощь! Спасибо!
Для меня, ваша окончательная цена 'двойной finalPrice = цена - per'. Нет? – gahfy
Я думаю, вы забыли TypeCast ** ePercent **, чтобы удвоить. –
Как это сделать? Я уже бросил цену вдвое! – user3051834