I am using an implementation for a backspace button for a calculator, but when I erase two or more numbers and click again another number it gave me the ones I erase with the new ones, for example, I put 2569 and when I push backspace to 25 and push the button 7 its gave me 25697, any idea, here is the code for the backspace button.
btnBackSpace.setOnClickListener( new OnClickListener(){
public void onClick(View arg0){
String str=editX.getText().toString();
if (str.length() >1 ) {
str = str.substring(0, str.length() - 1);
editX.setText(str);
}
else if (str.length() <=1 ) {
editX.setText("0");
}
}
});