Advertisement
Guest User

Untitled

a guest
Jan 19th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.87 KB | None | 0 0
  1. /**
  2.  * Includes
  3.  */
  4. package idig.za.net.conscalc;
  5.  
  6. import android.app.Activity;
  7. import android.content.Intent;
  8. import android.content.SharedPreferences;
  9. import android.os.Bundle;
  10. import android.view.Menu;
  11. import android.view.MotionEvent;
  12. import android.view.View;
  13. import android.widget.Button;
  14. import android.widget.EditText;
  15.  
  16. /**
  17.  * @author josiah
  18.  *
  19.  */
  20. public class GetRegistration extends Activity {
  21.  
  22.     // set up shared preference file
  23.     public static final String PREFS_NAME = "MyPrefsFile";
  24.  
  25.     @Override
  26.     protected void onCreate(Bundle savedInstanceState) {
  27.         super.onCreate(savedInstanceState);
  28.         setContentView(R.layout.get_registration);
  29.         final Button saveRegistrationButton = (Button) findViewById(R.id.buttonSaveRegistration);
  30.         saveRegistrationButton.setOnClickListener(new View.OnClickListener() {
  31.             @Override
  32.             public void onClick(View arg0) {
  33.                 EditText editTextRegistration = (EditText) findViewById(R.id.editTextRegistration);
  34.                 String registrationNumber = editTextRegistration.getText().toString();
  35.  
  36.                 // create shared preference object - settings
  37.                 SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
  38.                 // create a shared preference editor to modify the shared preferences
  39.                 SharedPreferences.Editor editor = settings.edit();
  40.                 // put the variables in the editor
  41.                 editor.putBoolean("registrationIsSet", true);
  42.                 editor.putString("registrationNumber", registrationNumber);
  43.                 // Commit the edits
  44.                 editor.commit();
  45.  
  46.                 // create an intent object and tell it where to go
  47.                 Intent myIntent = new Intent(GetRegistration.this, CalcMenu.class);
  48.                
  49.                 // start the intent
  50.                 startActivity(myIntent);
  51.             }
  52.         });
  53.     }
  54.  
  55.     @Override
  56.     public boolean onCreateOptionsMenu(Menu menu) {
  57.         // Inflate the menu; this adds items to the action bar if it is present.
  58.         getMenuInflater().inflate(R.menu.activity_main, menu);
  59.         return true;
  60.     }
  61. }
  62.  
  63.  
  64. /**
  65.  * Includes
  66.  */
  67. package idig.za.net.conscalc;
  68.  
  69. import android.app.Activity;
  70. import android.content.Intent;
  71. import android.os.Bundle;
  72. import android.view.Menu;
  73. import android.view.MotionEvent;
  74. import android.view.View;
  75. import android.widget.Button;
  76.  
  77. /**
  78.  * @author josiah
  79.  *
  80.  */
  81. public class CalcMenu extends Activity {
  82.  
  83.     @Override
  84.     protected void onCreate(Bundle savedInstanceState) {
  85.         super.onCreate(savedInstanceState);
  86.         setContentView(R.layout.calc_menu);
  87.        
  88.         // create a button object
  89.         final Button buttonAddRecord = (Button) findViewById(R.id.buttonAddRecord);
  90.         // attach a listener to the button
  91.         buttonAddRecord.setOnClickListener(new View.OnClickListener() {
  92.             @Override
  93.             public void onClick(View v) {
  94.                 // create an Intent object for this activity, including its destination class
  95.                 Intent myIntent = new Intent(CalcMenu.this, AddRecord.class);
  96.                 // run the activity
  97.                 startActivity(myIntent);
  98.             }
  99.         });
  100.        
  101.         // create a button object
  102.         final Button buttonCalculateConsumption = (Button) findViewById(R.id.buttonCalculateConsumption);
  103.         // attach a listener to the button
  104.         buttonAddRecord.setOnClickListener(new View.OnClickListener() {
  105.             @Override
  106.             public void onClick(View v) {
  107. //              // create an Intent object for this activity, including its destination class
  108. //              Intent myIntent = new Intent(CalcMenu.this, CalculateConsumption.class);
  109. //              // run the activity
  110. //              startActivity(myIntent);
  111.             }
  112.         });
  113.        
  114.         // create a button object
  115.         final Button buttonDeleteRecord = (Button) findViewById(R.id.buttonDeleteRecord);
  116.         // attach a listener to the button
  117.         buttonAddRecord.setOnClickListener(new View.OnClickListener() {
  118.             @Override
  119.             public void onClick(View v) {
  120. //              // create an Intent object for this activity, including its destination class
  121. //              Intent myIntent = new Intent(CalcMenu.this, DeleteRecord.class);
  122. //              // run the activity
  123. //              startActivity(myIntent);
  124.             }
  125.         });
  126.        
  127.         // create a button object
  128.         final Button buttonEditRecord = (Button) findViewById(R.id.buttonEditRecord);
  129.         // attach a listener to the button
  130.         buttonAddRecord.setOnClickListener(new View.OnClickListener() {
  131.             @Override
  132.             public void onClick(View v) {
  133.                 // TODO Auto-generated method stub
  134.             }
  135.         });
  136.     }
  137.  
  138.     @Override
  139.     public boolean onCreateOptionsMenu(Menu menu) {
  140.         // Inflate the menu; this adds items to the action bar if it is present.
  141.         getMenuInflater().inflate(R.menu.activity_main, menu);
  142.         return true;
  143.     }
  144. }
  145.  
  146.  
  147. package idig.za.net.conscalc;
  148.  
  149. import android.os.Bundle;
  150. import android.app.Activity;
  151. import android.view.Menu;
  152. import android.view.MenuItem;
  153. import android.support.v4.app.NavUtils;
  154.  
  155. public class AddRecord extends Activity {
  156.  
  157.     @Override
  158.     protected void onCreate(Bundle savedInstanceState) {
  159.         super.onCreate(savedInstanceState);
  160.         setContentView(R.layout.add_record);
  161.         // Show the Up button in the action bar.
  162. //      getActionBar().setDisplayHomeAsUpEnabled(true);
  163.     }
  164.  
  165. //  @Override
  166. //  public boolean onCreateOptionsMenu(Menu menu) {
  167. //      // Inflate the menu; this adds items to the action bar if it is present.
  168. //      getMenuInflater().inflate(R.menu.add_record, menu);
  169. //      return true;
  170. //  }
  171.  
  172. //  @Override
  173. //  public boolean onOptionsItemSelected(MenuItem item) {
  174. //      switch (item.getItemId()) {
  175. //      case android.R.id.home:
  176. //          // This ID represents the Home or Up button. In the case of this
  177. //          // activity, the Up button is shown. Use NavUtils to allow users
  178. //          // to navigate up one level in the application structure. For
  179. //          // more details, see the Navigation pattern on Android Design:
  180. //          //
  181. //          // http://developer.android.com/design/patterns/navigation.html#up-vs-back
  182. //          //
  183. //          NavUtils.navigateUpFromSameTask(this);
  184. //          return true;
  185. //      }
  186. //      return super.onOptionsItemSelected(item);
  187. //  }
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement