Android Question Max Chars in Edit Text

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I've searched this form, but my question is different from what most people ask and answers that are provided.

I have a Multi-Line EditText that is sized to match almost the full size of the phones display.

I am displaying the output of Speech Recognition. When new speech is recognized, the text is added to the end of the EditText and is scrolled into view by setting the selection start location – kind of like a video display terminal.

This gives me a scrolling display of recognized speech.

I have found that after an hour or two new speech stops being displayed in the EditText. If I clear the EditText, new speech is displayed as expected.

I don't know if it's because:
  1. The text buffer of the EditText Is full.
  2. The EditText has reached the maximum number of characters it can display.
  3. The EditText has reached the maximum number of lines it can display.
Does anyone know what the limits are for the total number of characters an edit text can hold, display, or number of lines it can display?

Are these maximum values device or Android version dependent?

Thanks,
Barry.
 

canalrun

Well-Known Member
Licensed User
Longtime User
There are limits on some devices.

It makes sense to control the string length:
B4X:
If EditText1.Text.Length > 10000 Then
 EditText.Text = EditText.Text.Substring2(5000, EditText.Text.Length)

I have attached a really quick and dirty test app to test the maximum text length of an EditText.

I get a maximum length of 10,500 characters on one phone, over 40,000 on a different phone.

I use Erel's suggestion to limit the text length.

upload_2018-4-19_13-48-45.png


This test app is also a good starting place if you need to develop a test app for testing some other feature of an EditText.

Barry.
 

Attachments

  • edTxtTst.zip
    8 KB · Views: 274
Upvote 0
Top