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

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.mastermind">
package="com.example.mastermind" >
<application
android:allowBackup="true"
@ -12,15 +12,28 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
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
android:name=".MainActivity"
android:exported="true">
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>

View File

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