EditText - issues editing text from default value

yonson

Active Member
Licensed User
Longtime User
Hi,
I've got a query regarding edittext. I've added an edit text programmatically (ie NOT using the designer - I actually can't because I'm adding in an undetermined array of edittext views), everything works fine except that when I try to edit the initial text value, the original remains on screen, overlaying the edited one, i.e. both the original text value and the edited one show at the same time.

For example :-

Dim edt_input As EditText
edt_input.Initialize("edt_input")
edt_input.Tag="field"
edt_input.Text="default"

for this, if I try and edit the text, the word 'default' remains on the label in addition to whatever edit I do.

I thought a possible solution might be to implement the 'TextChanged' call, for example

Sub edt_input_TextChanged (Old As String, New As String)
Dim Send As EditText
Send=Sender
Send.Text= New
End Sub

However this is causing the app to crash.

Just wondering if anyone could advise a workaround for this?

Many thanks in advance!
 

yonson

Active Member
Licensed User
Longtime User
Thanks Erel, unfortunately that doesn't work as I tried that at the start.

I'll try and explain a little more for context, basically I'm creating a generic view class which might render a label view, edit text view etc etc, so at runtime I don't know exactly what the views will be, but create them from a class.

The core method in the class is (I've removed other code that isn't relevant):

Sub Class_Globals
Dim edt_input As EditText
End Sub

Sub RenderInput As View
Select InputType
Case "text"
' cast as text
edt_input.Initialize("edt_input")
edt_input.Tag="field"
edt_input.Text="default"
Return edt_input
End Select
End Sub

Sub edt_input_TextChanged (Old As String, New As String)
Log("old and new : "&Old&" / "&New& "/"&edt_input.Text)
End Sub

For this code, everything works great, except that the EditView always contains 2 overlaying label - the new one I'm editing, and the original 'default' value that I set it up with initially.

I've tried a few different approaches, re-initialising the view, changing the sender text, changing the edt_input.Text value etc, all of these case the app to crash.

Any ideas? As I say works fine if its added in from the designer but can't do that as I need a dynamic layout.

Thanks
 
Upvote 0

yonson

Active Member
Licensed User
Longtime User
Fixed

Actually its not the edit text itself, but the panel its being rendered upon which is being duplicated, not sure exactly how at the moment but just wanted to clarify that I've identified the issue.

Thanks for your help
 
Upvote 0
Top