Guest User

Untitled

a guest
Jun 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1. package com.logs.log_tables;
  2.  
  3. import android.app.Activity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6.  
  7.  
  8. public class FormulaAndTablesActivity extends Activity {
  9.     Integer current_menu;
  10.    
  11.     /** Called when the activity is first created. */
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.        
  16.         Integer location = null;
  17.         location = (savedInstanceState == null) ? null : savedInstanceState.getInt("location");
  18.        
  19.         if(location == null) {
  20.             setContentView(R.layout.main_menu);
  21.         }
  22.        
  23.         else {
  24.             switch(location) {
  25.             case 0: current_menu = 0; setContentView(R.layout.main_menu); break;
  26.             case 1: current_menu = 1; setContentView(R.layout.mechanics_menu); break;
  27.             case 2: current_menu = 2; setContentView(R.layout.statistics_menu); break;
  28.             case 3: current_menu = 3; setContentView(R.layout.coordinate_geo); break;
  29.             case 4: current_menu = 4; setContentView(R.layout.trigonometry); break;
  30.             case 5: current_menu = 5; setContentView(R.layout.logs); break;
  31.             default: current_menu = 0; setContentView(R.layout.main_menu); break;
  32.             }
  33.         }
  34.     }
  35.  
  36.     @Override
  37.     protected void onSaveInstanceState(Bundle out_state) {
  38.         super.onSaveInstanceState(out_state);
  39.         Integer location = get_location();
  40.        
  41.         out_state.putInt("location", location);
  42.     }
  43.    
  44.     public Integer get_location() {
  45.         return current_menu;
  46.     }
  47.    
  48.    
  49.     public void gotoHome(View v) {
  50.         current_menu = 0;
  51.         setContentView(R.layout.main_menu);
  52.     }
  53.    
  54.     public void gotoMechanics(View v) {
  55.         current_menu = 1;
  56.         setContentView(R.layout.mechanics_menu);
  57.     }
  58.    
  59.     public void gotoStatistics(View v) {
  60.         current_menu = 2;
  61.         setContentView(R.layout.statistics_menu);
  62.     }
  63.    
  64.     public void gotoCoordinateGeo(View v) {
  65.         current_menu = 3;
  66.         setContentView(R.layout.coordinate_geo);
  67.     }
  68.    
  69.     public void gotoTrig(View v) {
  70.         current_menu = 4;
  71.         setContentView(R.layout.trigonometry);
  72.     }
  73.    
  74.     public void gotoLogs(View v) {
  75.         current_menu = 5;
  76.         setContentView(R.layout.logs);
  77.     }
  78. }
Add Comment
Please, Sign In to add comment