So I have this program that has tiers of pages. Everything works fine, but when I slide the phone open, it starts the program over again.
I assume something is wrong with my onCreate function, I just don't know what it is.
Thank for any help.
Edit: apparently I failed at looking before, I put "android:configChanges="orientation|keyboardHidden" in the manifest and it works now.
Using java Syntax Highlighting
- public class PhysicsFusion extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- rootMenu();
- }
- //first tier
- public void rootMenu() {
- setContentView(R.layout.main);
- final Button physics = (Button) findViewById(R.id.physics);
- final Button chemistry = (Button) findViewById(R.id.chemistry);
- final Button genMath = (Button) findViewById(R.id.math);
- physics.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- physics();
- }
- });
- chemistry.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- chemistry();
- }
- });
- genMath.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- genMath();
- }
- });
- }
- //second tier
- public void physics() {
- setContentView(R.layout.physics);
- final Button statics = (Button) findViewById(R.id.statics);
- final Button em = (Button) findViewById(R.id.em);
- final Button mechanics = (Button) findViewById(R.id.mechanics);
- statics.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- statics();
- }
- });
- em.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- em();
- }
- });
- mechanics.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- mechanics();
- }
- });
- }
- public void chemistry() {
- }
- public void genMath() {
- }
- //third tier
- //physics
- protected ListView forcesList;
- protected ArrayList<Force> forces = new ArrayList<Force>();
- public void statics() {
- setContentView(R.layout.statics);
- final EditText force = (EditText) findViewById(R.id.staticsForce);
- final EditText angle = (EditText) findViewById(R.id.staticsAngle);
- final Button add = (Button) findViewById(R.id.staticsAdd);
- this.forcesList = (ListView) this.findViewById(R.id.forcesList);
- final Button compute = (Button) findViewById(R.id.staticsCompute);
- add.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- float temp1 = Float.parseFloat(force.getText().toString());
- float temp2 = Float.parseFloat(angle.getText().toString());
- forces.add(new Force(temp1, temp2));
- refreshForceList();
- force.setText("");
- angle.setText("");
- }
- });
- }
- private void refreshForceList() {
- forcesList.setAdapter(new ArrayAdapter<Force>(this, android.R.layout.simple_list_item_1, forces));
- }
- public void em() {
- }
- public void mechanics() {
- }
- }
Parsed in 0.043 seconds, using GeSHi 1.0.8.4

