0
如何創建操作歷史記錄?如何爲Android應用創建歷史記錄?
我需要將結果保存在數組中,然後在Android中使用ListActivity重新存儲結果。
這是代碼:
public void calculator(){
EditText screen = (EditText) findViewById(R.id.screen);
if (screen.getText().toString().equals(".")){
screen.setText("0");
}
if (screen.getText().toString().length() > 0){
this.Operand2 = Float.parseFloat(screen.getText().toString());
}
if (this.Operator.equals("+")) {
this.Answer = this.Operand1 + this.Operand2;
} else if (this.Operator.equals("-")){
this.Answer = this.Operand1 - this.Operand2;
} else if (this.Operator.equals("*")){
this.Answer =this.Operand1 * this.Operand2;
} else if (this.Operator.equals("/")){
this.Answer = this.Operand1/this.Operand2;
}else if (this.Operator.equals("^")){
this.Answer = (float) Math.pow(this.Operand1, this.Operand2);
}else if (this.Operator.equals("%")){
this.Answer = Operand1 % this.Operand2;
}else{
this.Answer = Float.parseFloat(screen.getText().toString());
}
screen.setText(this.Answer + "");
而這正是數組適配器:
la1 = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, ARRAY_NAME);