1. Are you ready for the Galaxy S20? Here is everything we know so far!

I need help with subroutines (methods)

Discussion in 'Android Development' started by Rob Sleurs, Sep 25, 2020.

  1. Rob Sleurs

    Rob Sleurs Lurker
    Thread Starter

    Hello,
    In an app that i 'm writing i 've code that is the same for several views, it is code to save/load data in different files views are: parameters, history,personal info, medication. files are parameters.txt, history.txt, medication.txt
    How should i create a kind of util class with code in for save/load data?
    this is the code for history view:
    public class geschiedenis extends AppCompatActivity {
    public static final Object EXTRA_MESSAGE = "com.example.Gezondheidzlogin.MESSAGE";
    //variables
    String jaartal,diagnose,behandeling, titel;
    EditText injaartaltext,indiagnosetext,inbehandelingtext;
    @override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_inputgeschiedenis);
    Intent intent3 = getIntent();
    }

    public void savedata (View view) {

    //laad gegevens in in object voor te versturen naar verwerking
    String jaartal;
    EditText editText = (EditText) findViewById(R.id.injaartaltext);
    jaartal = editText.getText().toString() + ",";
    //intent.putExtra(EXTRA_MESSAGE, jaartal);
    String diagnose;
    editText = (EditText) findViewById(R.id.indiagnosetext);
    diagnose = editText.getText().toString()+",";
    //intent.putExtra(EXTRA_MESSAGE, diagnose);

    editText = (EditText) findViewById(R.id.inbehandelingtext);
    behandeling = editText.getText().toString();
    String result = "GESCHIEDENIS" + jaartal +diagnose + behandeling;
    Intent intent13 = new Intent(this, activity_processing.class);
    intent13.putExtra((String) EXTRA_MESSAGE, result);

    startActivity(intent13);
    }
    public void startexit (View view) {
    Intent intent100 = new Intent(this, startexit.class);
    startActivity(intent100);
    finish();
    System.exit(0);
    }
    public void startmenu(View view) {
    Intent intent = new Intent(this, MainActivity.class);
    startActivity(intent);
    }
    }
    thx for help, Rob​
     


Loading...

Share This Page

Loading...