B4J Question AS Settings: How to clear / delete existing properties successfully to re-use the component?

Mashiane

Expert
Licensed User
Longtime User
Hi

I want to re-use the same AS Settings component but show different properties depending on some click event. To demonstrate, I have added 2 buttons, to show 1 set of properties and another set of properties but using the same AS Settings component. What Im expecting is that each button click will clear / delete existing properties and create new ones. Instead, the properties are "appended", the existing groups not being cleared.

Clicking Show Page, this should appear, ONLY.

1695832345945.png


Clicking Show Component, this should appear ONLY.

1695832460665.png


Now click "Show Page" and or "Show Component" a couple of more times and notice what happens to the right scroll bar of the app. Current existing properties are not cleared.

How can I solve this, I need the existing groups to be cleared and all existing properties to be cleared and not added on.

Thank you so much.
 

Attachments

  • ASSettingReuse.zip
    4.5 KB · Views: 67

Alexander Stolte

Expert
Licensed User
Longtime User
It's better to use 2 AS_Settings. But for the case you dont want a clean transition, i have added a ResetGroups function in V1.03.
This will reset the internal list and you can add other properties that were not visible before.

B4X:
Sub ShowPage
    B4XPages.SetTitle(Me,"Page Settings")

    'clear all existing properties if they exist?
    AS_Settings1.ResetGroups
    AS_Settings1.AddGroup("Page","Page Settings")
    'Boolean
    AS_Settings1.AddProperty_Boolean("Page","PropertyName_1","Boolean Property True","Description Test Text",Null,True)
    AS_Settings1.AddProperty_Boolean("Page","PropertyName_2","Boolean Property False","Description Long Long Long Long Long Long Long Long Long Long Long Long Long Long Test Text",Null,False)
    AS_Settings1.AddProperty_Boolean("Page","PropertyName_3","Boolean Property True with a long text","",Null,True)
    'Action Button
    AS_Settings1.AddProperty_Action("Page","PropertyName_4","Action Property","",Null,"English")
    AS_Settings1.AddProperty_Action("Page","PropertyName_5","Icon","",AS_Settings1.FontToBitmap(Chr(0xF179),False,30,xui.Color_White),"English, German, Italian, Spanish, Swedish")
    AS_Settings1.AddProperty_ActionClean("Page","PropertyName_6","Delete Account","",AS_Settings1.FontToBitmap(Chr(0xE92B),True,34,xui.Color_White))
    AS_Settings1.AddProperty_Action("Page","PropertyName_7","Pro Feature","",Null,"Pro")
    
    AS_Settings1.BottomText = "Anele Mbanga" & CRLF & "V1.0.2"
    
    AS_Settings1.Create
End Sub

Sub ShowComponent
    B4XPages.SetTitle(Me,"Component Settings")
    'AS_Properties.DeleteAllProperties
    'clear all existing properties if they exist?
    AS_Settings1.ResetGroups
    
    AS_Settings1.AddGroup("Advanced","Component Settings")
    
    'Numeric Example
    AS_Settings1.AddProperty_Text("Advanced","PropertyName_8","Text Example","",Null,"Test",100dip,AS_Settings1.InputType_Text)
    AS_Settings1.AddProperty_Text("Advanced","PropertyName_9","Numeric Example","",Null,24,60dip,AS_Settings1.InputType_Numeric)
    AS_Settings1.AddProperty_Text("Advanced","PropertyName_10","Decimal Example","",Null,24.24,100dip,AS_Settings1.InputType_Decimal)
    'AS_Settings1.AddProperty_Text("Advanced","PropertyName_12","Decimal Example",Null,24.24,100dip,AS_Settings1.InputType_IPv4,"")
    'ComboBox
    AS_Settings1.AddProperty_ComboBox("Advanced","PropertyName_11","ComboBox Example","",Null,1,Array("Option 1","Option 2","Option 3","Option 4"))
    
    AS_Settings1.BottomText = "Sithaso Holdings" & CRLF & "V1.0.2"
    
    AS_Settings1.Create
End Sub
 
Upvote 0
Top