I created an application with user settings using Kotlin and the Preference Library, but I don't know how to close the settings screen.
I want the title bar to go back when I press that button on top.
(I don't want to display the title bar except on the setting screen because it looks ugly.)
setting.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference
android:defaultValue="true"
android:key="OnOff"
android:summaryOn="On"
android:summaryOff="Off"
android: title="OnOff"/>
<ListPreference
android:defaultValue="OFF"
android:entries="@array/reply_entries"
android:entryValues="@array/reply_values"
android:key="level"
android: title="List preference"
app:useSimpleSummaryProvider="true"/>
</PreferenceScreen>
Seeting.kt
package com.example.myapp
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.preference.PreferenceFragmentCompat
import com.example.sugoidentaku.R
class Setting:PreferenceFragmentCompat(){
override fun onCreatePreferences (savedInstanceState: Bundle?, rootKey: String?) {
// Configure the settings screen according to the res/xml/preferences.xml file
setPreferencesFromResource(R.xml.setting, rootKey)
}
MainActivity.kt
supportFragmentManager
.beginTransaction()
.replace(R.id.setting,Setting())
.commit()
Wouldn't it be better to save the transaction with addToBackStack
?
supportFragmentManager
.beginTransaction()
.replace(R.id.setting,Setting())
.addToBackStack (null)
.commit()
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
581 PHP ssh2_scp_send fails to send files as intended
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.