-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingsActivity.java
More file actions
58 lines (47 loc) · 1.81 KB
/
SettingsActivity.java
File metadata and controls
58 lines (47 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.Go.GoCart;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
public class SettingsActivity extends AppCompatActivity {
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
toolbar = findViewById(R.id.toolbar_settings);
setSupportActionBar(toolbar);
if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
getFragmentManager().beginTransaction().add(R.id.fragment_container, new SettingsFragment()).commit();
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("pressed", "pressed");
Intent intent = new Intent(SettingsActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
@Override
public void onBackPressed() {
startActivity(new Intent(SettingsActivity.this, MainActivity.class));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.settings_menu, menu);
return true;
}
public void savePrefs() {
SharedPreferences sharedPreferences = getSharedPreferences("Shared_Preferences", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
}
}