Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Includes
- */
- package idig.za.net.conscalc;
- import android.app.Activity;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- /**
- * @author josiah
- *
- */
- public class GetRegistration extends Activity {
- // set up shared preference file
- public static final String PREFS_NAME = "MyPrefsFile";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.get_registration);
- final Button saveRegistrationButton = (Button) findViewById(R.id.buttonSaveRegistration);
- saveRegistrationButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View arg0) {
- EditText editTextRegistration = (EditText) findViewById(R.id.editTextRegistration);
- String registrationNumber = editTextRegistration.getText().toString();
- // create shared preference object - settings
- SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
- // create a shared preference editor to modify the shared preferences
- SharedPreferences.Editor editor = settings.edit();
- // put the variables in the editor
- editor.putBoolean("registrationIsSet", true);
- editor.putString("registrationNumber", registrationNumber);
- // Commit the edits
- editor.commit();
- // create an intent object and tell it where to go
- Intent myIntent = new Intent(GetRegistration.this, CalcMenu.class);
- // start the intent
- startActivity(myIntent);
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.activity_main, menu);
- return true;
- }
- }
- /**
- * Includes
- */
- package idig.za.net.conscalc;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.Menu;
- import android.view.MotionEvent;
- import android.view.View;
- import android.widget.Button;
- /**
- * @author josiah
- *
- */
- public class CalcMenu extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.calc_menu);
- // create a button object
- final Button buttonAddRecord = (Button) findViewById(R.id.buttonAddRecord);
- // attach a listener to the button
- buttonAddRecord.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // create an Intent object for this activity, including its destination class
- Intent myIntent = new Intent(CalcMenu.this, AddRecord.class);
- // run the activity
- startActivity(myIntent);
- }
- });
- // create a button object
- final Button buttonCalculateConsumption = (Button) findViewById(R.id.buttonCalculateConsumption);
- // attach a listener to the button
- buttonAddRecord.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // // create an Intent object for this activity, including its destination class
- // Intent myIntent = new Intent(CalcMenu.this, CalculateConsumption.class);
- // // run the activity
- // startActivity(myIntent);
- }
- });
- // create a button object
- final Button buttonDeleteRecord = (Button) findViewById(R.id.buttonDeleteRecord);
- // attach a listener to the button
- buttonAddRecord.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // // create an Intent object for this activity, including its destination class
- // Intent myIntent = new Intent(CalcMenu.this, DeleteRecord.class);
- // // run the activity
- // startActivity(myIntent);
- }
- });
- // create a button object
- final Button buttonEditRecord = (Button) findViewById(R.id.buttonEditRecord);
- // attach a listener to the button
- buttonAddRecord.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- // TODO Auto-generated method stub
- }
- });
- }
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.activity_main, menu);
- return true;
- }
- }
- package idig.za.net.conscalc;
- import android.os.Bundle;
- import android.app.Activity;
- import android.view.Menu;
- import android.view.MenuItem;
- import android.support.v4.app.NavUtils;
- public class AddRecord extends Activity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.add_record);
- // Show the Up button in the action bar.
- // getActionBar().setDisplayHomeAsUpEnabled(true);
- }
- // @Override
- // public boolean onCreateOptionsMenu(Menu menu) {
- // // Inflate the menu; this adds items to the action bar if it is present.
- // getMenuInflater().inflate(R.menu.add_record, menu);
- // return true;
- // }
- // @Override
- // public boolean onOptionsItemSelected(MenuItem item) {
- // switch (item.getItemId()) {
- // case android.R.id.home:
- // // This ID represents the Home or Up button. In the case of this
- // // activity, the Up button is shown. Use NavUtils to allow users
- // // to navigate up one level in the application structure. For
- // // more details, see the Navigation pattern on Android Design:
- // //
- // // http://developer.android.com/design/patterns/navigation.html#up-vs-back
- // //
- // NavUtils.navigateUpFromSameTask(this);
- // return true;
- // }
- // return super.onOptionsItemSelected(item);
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement