Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Maschine_v1 extends Fragment {
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View rootView = inflater.inflate(R.layout.fragment_maschine_variante_1, container, false);
- //Variablen definieren, um die Daten aus den Feldern auszulesen
- TextView maschinenname_v1 = (TextView) rootView.findViewById(R.id.tv_m_v1_Maschine);
- TextView anschaffungswert_v1 = (TextView) rootView.findViewById(R.id.tv_m_v1_Anschaffungswert_Eintrag);
- TextView raumbedarf_v1 = (TextView) rootView.findViewById(R.id.tv_m_v1_Raumbedarf_Eintrag);
- TextView el_Anschlusswert_v1 = (TextView) rootView.findViewById(R.id.tv_m_v1_el_Anschlusswert_Eintrag);
- //Shared Preferences definieren
- SharedPreferences sharedpref = this.getActivity().getSharedPreferences("Datenspeicher", Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = sharedpref.edit();
- //Daten in benannter SharedPreference speichern
- editor.putString("maschinenname_v1", maschinenname_v1.getText().toString());
- editor.putString("anschaffungswert_v1", anschaffungswert_v1.getText().toString());
- editor.putString("raumbedarf_v1", raumbedarf_v1.getText().toString());
- editor.putString("el_anschlusswert_v1", el_Anschlusswert_v1.getText().toString());
- editor.commit();
- public class Werkzeug_v1 extends android.support.v4.app.Fragment {
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- final View rootView = inflater.inflate(R.layout.fragment_werkzeug_variante_1, container, false);
- TextView tv = (TextView) rootView.findViewById(R.id.tv_v1_Werkzeug_Abnutzung_Eintrag);
- TextView tv2 = (TextView) rootView.findViewById(R.id.tv_v1_Werkzeug_Schnittweg_Eintrag);
- SharedPreferences sharedPref = this.getActivity().getSharedPreferences("Datenspeicher", Context.MODE_PRIVATE);
- String test = sharedPref.getString("anschaffungswert_v1","N/A");
- String test2 = sharedPref.getString("schnittweg", "");
- tv.setText(test);
- tv2.setText(test2);
- <?xml version='1.0' encoding='utf-8' standalone='yes' ?>
- <map>
- <string name="anschaffungswert_v1"></string>
- <string name="maschinenname_v1"></string>
- <string name="schnittweg">1200</string>
- <string name="el_anschlusswert_v1"></string>
- <string name="losgroesse"></string>
- <string name="wstname">Werkstück 1</string>
- <string name="stueckzahl">33</string>
- <string name="raumbedarf_v1"></string>
- </map>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement