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

  • memo.png
    memo.png
    47.7 KB · Views: 154

Star-Dust

Expert
Licensed User
Longtime 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
 
Upvote 0

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
 
Upvote 0

Star-Dust

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

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.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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.
 
Upvote 0

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

  • Screenshot (364).png
    Screenshot (364).png
    43 KB · Views: 151
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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:
Upvote 0

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)
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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:
Upvote 0

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?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime 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

  • FiltriAcqua.zip
    56 KB · Views: 185
Upvote 0

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.
 
Upvote 0
Top