Wiec tak pisze kalkulator, zeby wstukiwac liczby zastosowalem taka metode:
public void getKeyboard(String str) {
String ScrCurrent = Scr.getText().toString();
if (ScrCurrent.equals("0"))
ScrCurrent = "";
ScrCurrent += str;
Scr.setText(ScrCurrent);
}
obliczenia jako select a wciskanie klawiszy jako default:
default:
String numb = ((Button) v).getText().toString();
getKeyboard(numb);
break;
nie umiem jednak sobie poradzic z bledem typu 5.............3 (czyli nieskonczona kropka)
Czego probowalem?
if (str != null && str.length() > 0 && str.charAt(str.length() - 1) == '.') {
str = str.substring(0, str.length() - 1);
}
oraz zliczac kropki i od kropki x nalozyc kasowanie, ale efekt byl jeszcze gorszy bo znikaly cyfry
if (str.equals(".") ) {
ScrCurrent = ".";
countDot++;
} else if(countDot >= 1) {
str = str.substring(0, str.length() - 1);
}
prosił bym o jakąs porade.