2016년 11월 29일 화요일

Using TinyDB with buttons


Hi there,

I am currently creating an app which is meant for drivers. Currently, I am wanting to create a on/off button to turn of the features, I have attached an image of the blocks and I have marked in a red pen the blocks for the on/off buttons. Now that is done, I wish to use TinyDB to save the users option for when they leave/close the app, the thing is, I do not know how to apply TinyDB to the buttons (I have used it for something else in the app but applying it to the buttons seem harder), could somebody kindly please help me with this.

Thanks.

Image of button in designer.JPG 표시 중

Blocks.JPG 표시 중

--
what about using only one button and changing the button text and color accordingly?
concerning TinyDB, see here TinyDB tutorial by Stephen
jusgt store on or off in a TinyDB tag of your choice and read it again in Screen,Initialize...

Taifun

-- 
Taifun, can you still use two buttons like me and use TinyDB?

Thanks.

-- 
yes you can
Taifun

-- 
Ok Taifun, 

I am just going to use the two buttons as so, I do know how to use TinyDB but I am just struggling using it with this particular two buttons. Are you able to guide me briefly?

Thanks.  

-- 
 Taifun wrote:
yes you can
Taifun

Ok so, I attempted to do it (I've attached an image of the blocks) but for some reason when you leave the app, none of the on and off button appears, what am I doing wrong? 

Thanks.
Blocks.png 표시 중

-- 
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun

-- 
 Taifun wrote:
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun



To be really honest Taifun, I don't know what you mean.  Can you please refine it?

Thanks.

-- 
Jude G wrote:

UTC+11, Taifun wrote:
if you want to store 2 tags in TinyDB, then you have to store both in the On.Click and Off.Click event
btw. you can do the same with only one tag, because if On is true, then Off is always false...
Taifun

To be really honest Taifun, I don't know what you mean.  Can you please refine it?

Thanks.



Okay, so I placed adjusted the tags for TinyDB (refer to attachment) but this time when you open and then close the app, both buttons appear! Now what am I doing wrong?

Thanks.
Blocks.png 표시 중

-- 
What is the purpose of having one button for ON and another for OFF? You can't have ON and OFF being true at the same time.

Why not a single switch button? Isn't that easier? (Please download the aia file and try it)

 Capture.jpg

-- 
 Italo wrote:
What is the purpose of having one button for ON and another for OFF? You can't have ON and OFF being true at the same time.

Why not a single switch button? Isn't that easier? (Please download the aia file and try it)





Hello Italo,

What do I put in the 'valueIfTagNotThere'. I want it to display 'off' if it can not find a tag.

See image for reference. Thanks!
Blocks.png 표시 중

-- 

What do I put in the 'valueIfTagNotThere'. I want it to display 'off' if it can not find a tag. 

OFF
Taifun

-- 
Okay thanks. When you enter the app after it being closed and had chosen the on button though, it has a red background and not a green one.

Image attached

Thanks.
Screenshot_2016-04-04-14-46-24.png 표시 중

-- 
In Screen1.Initialize, you retrieve the button text from TinyDB, good.
But you neglected to refresh the button color depending on its text.
ABG

-- 

댓글 없음:

댓글 쓰기