How to save a Disabled Button

At first the button is enabled, and when someone clicks a button, the button turns to its disabled state.


Button1.Enabled=False

i want to be able to save the button when its disabled so when the app is opened again, the button is still in its disabled state,

Anyhelp?
 

lagore

Active Member
Licensed User
Longtime User
The state manager is probably the best option, you can load default options first time round then save the settings as they are saved, not at my computer at the moment so can't show any code

Sent from my HTC Desire using Tapatalk 2
 
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
Statemanager is a code module not a library. Have you downloaded the zip file from the thread i linked to?
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You can save and load like this:

B4X:
Sub Globals
   Dim sets As Map
    sets.Initialize
End Sub

Sub savebtns
    sets.Clear
   sets.Put("EditText1", EditText1.Enabled)
   sets.Put("EditText2", EditText2.Enabled)
   File.WriteMap(File.DirInternal, "btnset.set", sets)
End Sub

Sub loadbtns
   sets = File.ReadMap(File.DirInternal, "btnset.set")
   EditText1.Enabled = sets.Get("EditText1")
   EditText2.Enabled = sets.Get("EditText2")
End Sub
 
Last edited:
Upvote 0

kickaha

Well-Known Member
Licensed User
Longtime User
I did not know that modules are not supported in the trial version.

May i suggest that you try and write the code yourself, and if you run in to problems we will gladly help. If you search the forum there are a lot of code snippets showing exactly what you need.

Edit:
The lovely Margret provided the code whilst I was typing
 
Last edited:
Upvote 0
okay, to set it i have this...

sets.Clear
sets.Put("adid", adidasiconButton.Enabled=false)
File.WriteMap(File.DirInternal, "btnset.set", sets)


and to get it i have this....

sets = File.ReadMap(File.DirInternal, "btnset.set")
adidasiconButton.Enabled = sets.Get("adid")

and im getting an error Cannot Parse: null as boolean when i press the button on the phone,, anyhelp please?
 
Last edited:
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You had an error in the code, you had adidasiconButton.Enabled=false. I removed the = false. The code below should work:

B4X:
sets.Clear
sets.Put("adid", adidasiconButton.Enabled) '=false) -this I removed
File.WriteMap(File.DirInternal, "btnset.set", sets)


sets = File.ReadMap(File.DirInternal, "btnset.set")
adidasiconButton.Enabled = sets.Get("adid")
 
Upvote 0
Top