I'm still relatively new to Android development, so please don't hold it against me. My problem is that I have created a preference activity for my program, but don't know how to access it so that the other activity uses/stores these values from startup. Furthermore, in the default settings activity, I don't have a toolbar with an arrow that takes me back to the first activity. I've tried a lot on the back arrow, but somehow nothing helped. Thank you very much.
Settings-Activity:
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings, new SettingsFragment())
.commit();
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
public static class SettingsFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.root_preferences, rootKey);
}
}
}
