B4A Library Preferences - Material Design Preferences

wimpie3

Well-Known Member
Licensed User
Seems like when you use AddListPreference and set DialogMessage to show a text above the list items, the items are gone and only the message is shown. Could be like that in the original library, not sure.
 

wimpie3

Well-Known Member
Licensed User
@corwin42 Thanks for the update. Unfortunately MultiSelectListPreference is missing some attributes like PositiveButtonText and NegativeButtonText (a must have for multilingual apps... AddListPreference has them, so again, I'm not sure if you left them out or if they are missing in the original library as well.

(edit: missing button texts on AddEditTextPreference as well)
 
Last edited:

corwin42

Expert
Licensed User
Seems like when you use AddListPreference and set DialogMessage to show a text above the list items, the items are gone and only the message is shown. Could be like that in the original library, not sure.
From the setDialogMessage() documentation:
Sets the message of the dialog. This will be shown on subsequent dialogs.

This message forms the content View of the dialog and conflicts with list-based dialogs, for example.
So this will not work with List based dialogs. I will remove the DialogMessage property from the list based preferences.
 
Last edited:

corwin42

Expert
Licensed User
@corwin42 Thanks for the update. Unfortunately MultiSelectListPreference is missing some attributes like PositiveButtonText and NegativeButtonText (a must have for multilingual apps... AddListPreference has them, so again, I'm not sure if you left them out or if they are missing in the original library as well.
Oops, I forgot the dialog methods in the wrapper for MultiSelectListPreference. I will add them.

Be aware that the default texts like "OK" and "'CANCEL" are localized by default.

(edit: missing button texts on AddEditTextPreference as well)
EditTextPreference has them. The AddXXXPreference methods only have the base parameters. If you need to set more you have to modify the preference after creation:
B4X:
    Dim etp As EditTextPreference
etp = PrefsView.AddEditTextPreference("Edit", "edittext1", "Sample EditText item", "Summary for the EditText", "123")
etp.NegativeButtonText="No way"
etp.DialogMessage="This is a message in the dialog"
Edit: If you find anything else that is missing, please post it. I will release a new version with the missing stuff later today.
 

wimpie3

Well-Known Member
Licensed User
The code I use is:

B4X:
Dim pv As MultiSelectListPreference
pv=cat1.AddMultiSelectListPreference("Multi", "multilist", "MultiSelectList Preference", "Select multiple Entries", Array As String("May"), Months, Months)
Crash log says:

B4X:
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.List cannot be cast to java.util.Set
    at net.xpece.android.support.preference.MultiSelectListPreference.onSetInitialValue(MultiSelectListPreference.java:195)
 

corwin42

Expert
Licensed User
The code I use is:

B4X:
Dim pv As MultiSelectListPreference
pv=cat1.AddMultiSelectListPreference("Multi", "multilist", "MultiSelectList Preference", "Select multiple Entries", Array As String("May"), Months, Months)
Crash log says:

B4X:
java.lang.ClassCastException: anywheresoftware.b4a.objects.collections.List cannot be cast to java.util.Set
    at net.xpece.android.support.preference.MultiSelectListPreference.onSetInitialValue(MultiSelectListPreference.java:195)
I see. Has nothing to do with API version. This is a bug in AddMultiSelectListPreference of the CategoryPreference.
I will fix it.
 

wimpie3

Well-Known Member
Licensed User
@corwin42 Thanks... I have encountered another problem in the mean time.

B4X:
Dim sd_textarea As EditTextPreference
sd_textarea.Initialize(PrefsView,"sd_textarea","fieldName","defaultvalue")
PrefsView.AddPreference(sd_textarea)
This gives the following error:
java.lang.IllegalArgumentException: method de.amberhome.preferences.PreferenceViewWrapper.AddPreference argument 1 has type net.xpece.android.support.preference.Preference, got net.xpece.android.support.preference.EditTextPreference

Does this mean EditTextPreferences cannot be created by using Initialize?
 

corwin42

Expert
Licensed User
Updated the library to V1.12 in the first post. It should fix all known problems and adds the possibility to remove a single key from the preferences.
 

johndb

Active Member
Licensed User
Thank you again for this excellent library @corwin42. Is there any way to decrease the vertical spacing between the preferences and section labels?

PrefScreen.png
 
Last edited:

wimpie3

Well-Known Member
Licensed User
I have noticed something strange in MultiSelectListPreference. The first checkbox is shown immediately, but the others only after a small delay. Did you see this behaviour as well? So with three checkboxes you immediately see the first checkbox, but the second and third only appear after a (short!) waiting period. If ONLY the second and the third checkbox are selected and NOT the first one, the delay is still visible on those.
 
Top