Hide a preference screen in android -
I have a priority xml ..
Load preferences from an XML resource first
AddLocationFram Resource (R. XML Preferences); And setting some default values for it ... After setting the default value, to hide one of my preference screen (not to delete)
My preference is XML
& lt; Priority xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Priority Android: Title = "Account Settings" Android: key = "customPref" /> & Lt; PreferenceScreen Android: title = "@ string / account_1" Android: key = "account" & gt; & Lt; EditTextPreference Android: key = "username" android: title = "@ string / settings_username" android: singleLine = "true" /> Android: password = "true" android: singleLine = "true" /> & Lt; / PreferenceScreen & gt; & Lt; PreferenceScreen Android: Title = "@ String / Account 2" Android: key = "account1" & gt; & Lt; EditTextPreference Android: key = "username1" android: title = "@ string / settings_username" android: singleLine = "true" /> Android: edit = & lt; / PreferenceScreen & gt; & Lt; / PreferenceScreen & gt; Let me hide the priority screen title = "@ string / account_2 You can duplicate your XML, then delete the second part as such:
& lt; PreferenceScreen xmlns: Android = "http://schemas.android.com/apk/res/android"> Priority Android: Title = "Account Settings" Android: key = "customPref" / & Gt; & lt; Priority Screen Android: Title = "@ String / Account_1" Android: Key = "Account" & gt; & lt; EditTextPreferenc E Android: key = "user name" Android: title = "@ string / settings_username" Android: singleLine = "true" /> & lt; Android: Android: single = "true" /> gt; & lt; / Priority screen & gt; & lt; / Preferences screen & gt; / Pre> Then you check your preference to see if it first
If yes, then you load the XML above, otherwise the first is not.
Comments
Post a Comment