65+ stand remember position and changes the theme.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.a1.nextlocation.fragments;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
@@ -20,6 +22,7 @@ import com.a1.nextlocation.R;
|
||||
public class SettingsFragment extends Fragment {
|
||||
|
||||
private ImageView imageButton;
|
||||
SwitchCompat fontChanger;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -46,6 +49,29 @@ public class SettingsFragment extends Fragment {
|
||||
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, homeFragment).addToBackStack(null).commit();
|
||||
});
|
||||
|
||||
|
||||
fontChanger = view.findViewById(R.id.BigFont);
|
||||
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences("com.a1.nextlocation",0);
|
||||
final SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
fontChanger.setChecked(sharedPreferences.getBoolean("switch",false));
|
||||
|
||||
fontChanger.setOnClickListener(view1 -> {
|
||||
if(fontChanger.isChecked())
|
||||
{
|
||||
requireActivity().setTheme(R.style.Theme_NextLocationBig);
|
||||
editor.putBoolean("switch",true);
|
||||
editor.apply();
|
||||
}
|
||||
if(!fontChanger.isChecked())
|
||||
{
|
||||
requireActivity().setTheme(R.style.Theme_NextLocation);
|
||||
editor.putBoolean("switch",false);
|
||||
editor.apply();
|
||||
}
|
||||
editor.commit();
|
||||
});
|
||||
|
||||
String[] items = new String[]{"Nederlands", "Engels", "Chinees"};
|
||||
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_dropdown_item, items);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user