First thing; I'm pretty much brand new to all this.
I've built a basic calculator but I lose the data when switching orientation (such as typing the number 9 then it going blank when switched to landscape).
I've already looked and found this: How to use onSavedInstanceState example please , but I'm unsure how to implement it into my code.
public class MainActivity extends AppCompatActivity {
private TextView _screen;
private String display = "";
private String currentOperator = "";
private String result = "";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
_screen = (TextView)findViewById(R.id.textView);
_screen.setText(display);
}
private void updateScreen(){
_screen.setText(display);
}
Can anyone help? An example using my piece would be perfect. Thanks