Ajout page parametre

This commit is contained in:
Claire G 2023-04-03 15:39:44 +02:00
parent f38eaf6b69
commit 2dc7b838c6
4 changed files with 60 additions and 6 deletions

View File

@ -13,6 +13,15 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.MasterMind" android:theme="@style/Theme.MasterMind"
tools:targetApi="31" > tools:targetApi="31" >
<activity
android:name=".SettingsActivity"
android:exported="false"
android:label="@string/title_activity_settings"
android:parentActivityName=".MainActivity">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:exported="true" > android:exported="true" >
@ -21,6 +30,10 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity> </activity>
</application> </application>

View File

@ -34,13 +34,13 @@ public class MainActivity extends Activity {
startActivity(tp2Intent); startActivity(tp2Intent);
} }
});*/ });*/
/*mSettings.setOnClickListener(new View.OnClickListener() { mSettings.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent tp3Intent = new Intent(MainActivity.this, Settings.class); Intent tp3Intent = new Intent(MainActivity.this, SettingsActivity.class);
startActivity(tp3Intent); startActivity(tp3Intent);
} }
});*/ });
/*mTP4.setOnClickListener(new View.OnClickListener() { /*mTP4.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View File

@ -0,0 +1,33 @@
package com.example.mastermind;
import android.os.Bundle;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.PreferenceFragmentCompat;
public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
if (savedInstanceState == null) {
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);
}
}
}

View File

@ -1,3 +1,11 @@
<resources> <resources>
<string name="app_name">MasterMind</string> <string name="app_name">MasterMind</string>
<string name="title_activity_settings">SettingsActivity</string>
<!-- Preference Titles -->
<string name="header">Paramètres</string>
<!-- Sync Preferences -->
<string name="pions_title">Autoriser les pions vides</string>
<string name="summary">Cette fonctionnalité augmente la difficultédu jeu pour l\'attaquant</string>
</resources> </resources>