Android Question AS Settings with segmented tab - how to set value in code?

Dave O

Well-Known Member
Licensed User
Longtime User
I'm trying out Alexander Stolte's AS Settings library for building preference pages (in my first B4XPages project).

I've added the ASSegmentedTab extension and it works well in the UI, but I can't figure out how to set its value in code, and haven't found an example on the forum.

In the B4XPage_Created event, I create the segmented tab:

B4X:
prefs.MainPage.AddProperty_SegmentedTab("GeneralSettings", "scoreToEnd", "Points to win", "", Null, "10000", CreateMap("3000":1, "5000":2, "10000":3), 0)

...then in the B4XPage_Appear event, I try to set it to a value saved in a map. First I tried:
B4X:
prefs.MainPage.GetProperty("scoreToEnd").Value = settingsMap.Get("scoreToEnd")

...but that didn't do anything, so I went back to the sample code and saw that I needed to drill down to the actual view and set its value, but tried this with no luck:
B4X:
prefs.MainPage.GetProperty("player1Name").View.As(B4XView).Text = settingsMap.Get("player1Name")   'this works
prefs.MainPage.GetProperty("scoreToEnd").View.As(ASSegmentedTab).Index = settingsMap.Get("scoreToEnd")   'this doesn't work

Any tips? Thanks!
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…