|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package but.androidstudio.tetris
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
|
import android.content.SharedPreferences
|
|
|
|
|
import android.os.Bundle
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import android.view.LayoutInflater
|
|
|
|
@ -25,21 +28,35 @@ class OptionFragment : Fragment() {
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
|
|
|
|
|
|
|
val spinnerDifficulty: Spinner = view.findViewById(R.id.spinnerDifficulty)
|
|
|
|
|
val spinnerDifficulty:Spinner = view.findViewById(R.id.spinnerDifficulty)
|
|
|
|
|
val difficulty = arrayOf("Easy","Medium","Hard")
|
|
|
|
|
|
|
|
|
|
/*val adaptateurSpinnerDifficulty = ArrayAdapter(this,android.R.layout.simple_spinner_dropdown_item,difficulty)
|
|
|
|
|
spinnerDifficulty.adapter = adaptateurSpinnerDifficulty
|
|
|
|
|
val adaptateurSpinnerDifficulty = ArrayAdapter(requireContext(),android.R.layout.simple_spinner_dropdown_item,difficulty)
|
|
|
|
|
adaptateurSpinnerDifficulty.setDropDownViewResource(android.R.layout.simple_spinner_item)
|
|
|
|
|
|
|
|
|
|
val monSpinner = requireView().findViewById<Spinner>(R.id.spinnerDifficulty)
|
|
|
|
|
monSpinner.adapter = adaptateurSpinnerDifficulty
|
|
|
|
|
|
|
|
|
|
spinnerDifficulty.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
|
|
|
|
override fun onItemSelected(parent: AdapterView<*>, view: View?, position: Int, id: Long) {
|
|
|
|
|
val selectedItem = parent.getItemAtPosition(position).toString()
|
|
|
|
|
// Faites quelque chose avec l'élément sélectionné
|
|
|
|
|
|
|
|
|
|
val sharedPref = activity?.getPreferences(Context.MODE_PRIVATE)
|
|
|
|
|
if (sharedPref != null) {
|
|
|
|
|
with(sharedPref.edit()){
|
|
|
|
|
putString("difficultyValue",selectedItem)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onNothingSelected(parent: AdapterView<*>) {
|
|
|
|
|
// Ne rien faire si aucun élément n'est sélectionné
|
|
|
|
|
val sharedPref = activity?.getPreferences(Context.MODE_PRIVATE)
|
|
|
|
|
if (sharedPref != null) {
|
|
|
|
|
with(sharedPref.edit()){
|
|
|
|
|
putString("difficultyValue",difficulty[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})*/
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|