I have an edit text field. The app will add a lot of text to this view. So I want to avoid having to rebuild the whole text of the view again and again. Can I just add text to the end of the current text in the edit text? I thought of using SelectionStart to set the cursor to the end of the text, but I am lacking a method to actually insert the text into the edit field there, like
B4X:
et.selectionstart = et.text.length
et.selection.text = moretext_at_the_end ' does not work
How do you do this?
Thanks.
Regards,
P.S. I sure don't feel like a "Senior Member", asking these kinds of questions... More like a novice verbose member...
et.text = et.text & newtext
or
Dim sb As StringBuilder
sb.Initialize
sb.Append(et.text).Append(newtext)
et.text = sb.ToString
If your text is very long, use the second method. That's a lot faster. And once sb is initialized, you just have to do:
sb.Append(newtext)
et.text = sb.ToString
to add a new text at the end.
Thanks for your suggestions. They both work, but the edit text has still to rebuild the whole edit text contents with both variants. This is what I want to avoid. Having programmed in RealBasic, I am used to a method that appends text to an edit field, without rebuilding the whole contents.
Thanks for your suggestions. They both work, but the edit text has still to rebuild the whole edit text contents with both variants. This is what I want to avoid. Having programmed in RealBasic, I am used to a method that appends text to an edit field, without rebuilding the whole contents.
And that has a noticeable effect ? I don't think so. You can replace the selection cursor where it was before the change. I use this in one of my app and it looks like I'm just adding text after the cursor, not rebuilding the whole thing.