-2
当我点击清除按钮它不会清除我写的数字。哪里不对?清除按钮无法正常工作
calcBtn.setOnClickListener(new View.OnClickListener() {
clearBtn.setOnClickListener(new View.OnClickListener(){
}
} {
@Override
public void onClick(View view) {
try {
float percentege = Float.parseFloat(percentageTxt.getText().toString());
float dec = percentege/100;
float total = dec * Float.parseFloat(numberTxt.getText().toString());
totalTextWiew.setText(Float.toString(total));
} catch (NumberFormatException nfe) {
totalTextWiew.setText("Error");
if (view==clearBtn);
numberTxt.clear
}
}
请正确格式的代码,以便我们可以尽力帮助。 – SoulRayder
你是否试图为相同的功能实现两个clicklistener? –