Android calculator: Backspace button
<p>I have recently designing for an android calculator, and the display is named fakedisplay.
i am now adding a backspace button for the calculator, and the code is as follows:</p>

<pre><code>    backspace.setOnClickListener(new View.OnClickListener() {        
        @Override 
        public void onClick(View v) { 

            clearCalcDisplay = DONT_CLEAR; 
            String str=Fakedisplay.getText().toString();
            if (str.length() &gt;=1 ) { 
                str = str.substring(0, str.length() - 1);
                Fakedisplay.setText(str);
                };
            if (str.length() &lt;1 ) {
                Fakedisplay.setText("0");
            }
    });   
</code></pre>

<p>My questions are that </p>

<ol>
<li><p>I have tried the above and it works for inputs longer than 1 characters, eg 145 it will give out 14, when it is 14 it gives out 1, but when further pressed, the program will be forced-close. Why?</p></li>
<li><p>And how to consider for decimal input?</p></li>
</ol>

<p>Would there be any better codes for this function?</p>
