Android Question Clear edit field immediatly

andredamen

Active Member
Licensed User
Longtime User
I want to clear an editfield. I program it with edtfield.clear. When I log the editfield I see it is empty but on the screen I stil see the old text. Later in the app I fill the editfield. It clears and fill with new text.
What I want: I want the clear the edit field and want to see a clear editfield immediatly on the screen. How can I do this?
 

andredamen

Active Member
Licensed User
Longtime User
Sorry I already programmed it with edithfield.text = "" I later fill the edit field but I want it on the screen imediatly empty.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upload a small project showing the problem. It is a bit unclear based on the infos you provided.

B4X:
editfield.Text = ""
- as mentioned above - does clear the text in the given editfield.
 
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
I clear it with: edtVeld.text = "" It clears the field, but not immeditaly on the screen. When I later in the program fill the field I can see it was cleared before.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
I clear it with: edtVeld.text = "" It clears the field, but not immeditaly on the screen. When I later in the program fill the field I can see it was cleared before.
try to call after setting the text to = ""
Activity.invalidate
this will redraw the whole screen and you should get a cleared textfield
 
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
B4X:
Private Sub btnOpnieuwTossen_Click
	TossenIsGelukt=False
	edtVeld.Text=""

	For ot = 1 To 40
		ToastMessageShow("Toss ronde nummer "& ot,False)
		GaOpnieuwTossen(ot)
	   If TossenIsGelukt Then Exit
	Next
	
End Sub


Private Sub GaOpnieuwTossen(hoevaak As Int)
Dim Doorgaan As Boolean

btnOpnieuwTossen.Enabled=False
MetSterkte= chkSterkte.Checked

SpelersIngepland = 0
edtVeld.Text=""
VoorkeurSpelerNaam =""
VoorkeurSpelerID = 0
VoorkeurSpelerSterkte=0
	
btnVeld1.Enabled=False
btnVeld2.Enabled=False
btnVeld3.Enabled=False
btnVeld4.Enabled=False
btnVeld5.Enabled=False
	
ZieVeld = 1

txt="DELETE FROM '"& Main.DBTableName1 & "' where datum =  '"&  Main.WelkeTossDatum & "' "   ' alle wedstrijden deze datum verwijderd
Main.SQL1.ExecNonQuery(txt)

'from here it fills a database afther making a toss



    VulEditVeld     ' this will fill the edit field with new data

End Sub

Private Sub VulEditVeld
	Dim Oudetijd As String
	Dim Dummy As Int
	
	
	WieNietIngetost 
	If TossenIsGelukt=False Then Return

	edtVeld.Text = "Indeling toss-wedstrijden "& Main.WelkeTossDatum & CRLF & CRLF

'from here it will fill the field further

End Sub
[\CODE]

It doesn't clear the field on the screen when I say edtVeld.text = "" . It fills from a cleared field when I fill the edtVeld later in the program.
 
Upvote 0

zed

Active Member
Licensed User
I see the code should work.
you are sure not to use edtVeld.Text in another line of code
Personally, this but already happened
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I tried to call
B4X:
B4XFloatTextField1.Text = ""
and it's cleared immediately.
 
Upvote 0

felixl

New Member
Maybe this helps:
B4X:
textfield.text = ""
sleep(0)

I think your sub is doing some heavy task? sleep allows the UI to refresh, without need to wait for the end of sub execution.

Greetings
 
Upvote 0

andredamen

Active Member
Licensed User
Longtime User
I tried to call
B4X:
B4XFloatTextField1.Text = ""
and it's cleared immediately.

You are a lucky one Sagenut.

B4X:
private Sub LeegEditVeld
	edtVeld.Text=""
	
	edtVeld.TextField.Text = "" 

	edtVeld.Text = "Indeling toss-wedstrijden "& Main.WelkeTossDatum & CRLF & CRLF
	
End Sub

Doesn't work with me.
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
The question is some how odd, thats why you should upload a minimal example project that demonstrates the following code which you claim it doesn't clear the text. It should cleared the text in any case
B4X:
B4XFloatTextField1.Text = ""
 
Upvote 0
Top