Android Question memorizzare una data

actarus63

Member
Licensed User
Salve a tutti, avrei bisogno di un aiuto di programmazione.
Ho creato un app con 4 pulsanti che funziona bene molto semplice nel suo uso. Ora con un pulsante dedicato, faccio apparire un pannel dove ho inserito una EditText1 quindi nella globals ho inserito la seguente stringa
Private EditText1 As EditText .
Allo interno del pulsante ho inserito la seguente stringa
Sub button1_click
EditText1.Text = "scrivi qui la data "
End sub
Quando clicco il pulsante mi apre il pannel che ho inserito, riesco a scrivere la data ma di fatto non me la fa memorizza, sicuramente il tipo di programmazione che utilizzo è troppo semplice, qualcuno puo’ indicarmi la giusta via ?
Ringrazio per la pazienza
 

Attachments

Star-Dust

Expert
Licensed User
Salve a tutti, avrei bisogno di un aiuto di programmazione.
Ho creato un app con 4 pulsanti che funziona bene molto semplice nel suo uso. Ora con un pulsante dedicato, faccio apparire un pannel dove ho inserito una EditText1 quindi nella globals ho inserito la seguente stringa
Private EditText1 As EditText .
Allo interno del pulsante ho inserito la seguente stringa
Sub button1_click
EditText1.Text = "scrivi qui la data "
End sub
Quando clicco il pulsante mi apre il pannel che ho inserito, riesco a scrivere la data ma di fatto non me la fa memorizza, sicuramente il tipo di programmazione che utilizzo è troppo semplice, qualcuno puo’ indicarmi la giusta via ?
Ringrazio per la pazienza
I'm sorry I don't understand Spanish.

The forum is English it would be useful to translate into English and post a piece of code.

Alternatively you can write in the forum dedicated to your language
 

actarus63

Member
Licensed User
Hi everyone, I need some programming help.
I created an app with 4 buttons that works well very simple in its use. Now with a dedicated button, I bring up a pannel where I inserted an EditText1 then in the globals I inserted the following string
Private EditText1 As EditText.
Inside the button I entered the following string
Sub button1_click
EditText1.Text = "write the date here"
End sub
When I click the button, the panel I entered opens, I can write the date but in fact it does not memorize it, surely the type of programming I use is too simple, can someone show me the right way?
Thank you for your patience

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.


Private EditText1 As EditText
End Sub

Sub Button5_Click


EditText1.Text = "scrivi qui la data "


End Sub
 

Star-Dust

Expert
Licensed User
What you write remains stored in editText1. What exactly did you want to achieve?
 

actarus63

Member
Licensed User
what I write, does not remain stored in editText1, I ask for a support how to modify the code, if it was not too complicated, unless, I do not have to modify part of the app.
 

Star-Dust

Expert
Licensed User
what I write, does not remain stored in editText1, I ask for a support how to modify the code, if it was not too complicated, unless, I do not have to modify part of the app.
If you click on button5 again the content is replaced since it assigns a new value to the Text property.
 

actarus63

Member
Licensed User
when I click the button it gives me the opportunity to write, and I enter the date, but when I click the button I start over, it doesn't memorize the writing, so I deduce that I did something wrong in the programming
 

Attachments

Star-Dust

Expert
Licensed User
Keep the value in a global variable
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim NextData As String
End Sub
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    NextData=New
End Sub
However I would remove this and replace it as in the example
B4X:
Sub Button5_Click
   'EditText1.Text = "scrivi qui la data "
   EditText1.Hint = "Digit a new data"
End Sub
 

Star-Dust

Expert
Licensed User
when I click the button it gives me the opportunity to write, and I enter the date, but when I click the button I start over, it doesn't memorize the writing, so I deduce that I did something wrong in the programming
This instruction deletes anything else that has been written before
B4X:
Sub Button5_Click
   EditText1.Text = "scrivi qui la data " 'This instruction deletes anything else that has been written before
End Sub
Better if instead insert a label with the indication of the field.
 
Last edited:

actarus63

Member
Licensed User
Keep the value in a global variable
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim NextData As String
End Sub
B4X:
Sub EditText1_TextChanged (Old As String, New As String)
    NextData=New
End Sub
However I would remove this and replace it as in the example
B4X:
Sub Button5_Click
   'EditText1.Text = "scrivi qui la data "
   EditText1.Hint = "Digit a new data"
End Sub

unfortunately nothing happens except that everything remains unchanged, in fact the nextdata variable in the process globas gives the following error (Main - 25: Unused 'NextData' variable. (warning # 9)
 

Star-Dust

Expert
Licensed User
unfortunately nothing happens except that everything remains unchanged, in fact the nextdata variable in the process globas gives the following error (Main - 25: Unused 'NextData' variable. (warning # 9)
You will have forgotten something. Better if you post your code. Create a ZIP and post it.

1596298574647.png


Add a few notes to understand what this App is used for
 

Star-Dust

Expert
Licensed User
I also fixed the Layout which was too cheated. However, the mistake was that you wrote in EditText.

However in your example it is not clear where you use the string you acquire from edittext. On slq? On the Internet? PHP?

To keep that data until the next restart of the App you have to keep the data somewhere. In a file, in a database, or if you rely on a server service with a php you can save the data on the server.
Otherwise, when you close and reopen the App, the data entered is lost.
 
Last edited:

actarus63

Member
Licensed User
I also fixed the Layout which was too cheated. However, the mistake was that you wrote in EditText.

However in your example it is not clear where you use the string you acquire from edittext. On slq? On the Internet? PHP?

To keep that data until the next restart of the App you have to keep the data somewhere. In a file, in a database, or if you rely on a server service with a php you can save the data on the server.
Otherwise, when you close and reopen the App, the data entered is lost.
I see the change, but in fact this is the problem, I must definitely insert I have the dbsql, or an execel file for the date to be stored, right?
 

Star-Dust

Expert
Licensed User
I added the local save of the entered data.

PS. However, your question was badly worded. EditText is not true that it does not retain the data. Obviously all views and variables are volatile and when the App is restarted they are reset.
The behavior of your code is correct for how you developed it

The question would have been: "How should I keep data acquired from an edittext so that it reappears on the next reboot?"
 

Attachments

LucaMs

Expert
Licensed User
Note that instead of:
EditText1.Text = "write the date here"
you can/should use:

EditText1.Hint = "write the date here"

and if it doesn't have to change at runtime you should set it (Hint) in the Designer.
 
Last edited:

actarus63

Member
Licensed User
Note that instead of:

you can/should use:

EditText1.Hint = "write the date here"

and if it doesn't have to change at runtime you should set it (Hint) in the Designer.
ok, as soon as i make the change i will let you know if it works thanks
 

actarus63

Member
Licensed User
I added the local save of the entered data.

PS. However, your question was badly worded. EditText is not true that it does not retain the data. Obviously all views and variables are volatile and when the App is restarted they are reset.
The behavior of your code is correct for how you developed it

The question would have been: "How should I keep data acquired from an edittext so that it reappears on the next reboot?"
Thanks for the compliment on the simplicity of how I developed the app. Your help was fundamental in understanding how I should intervene and make the change. Thanks to everyone.
 
Top