What wrong with EditText1.InputType

bsnqt

Active Member
Licensed User
Longtime User
I have one long String that I load into EditText1.
My string contains many characters that are the line break such as Chr(13) or CRLF

I don't want the user to key in nor make any input to my EditText which is only giving information (not for input). That is why I put the last line of code into my declaration of EditText1 view, in order to prevent the display of keyboard.

B4X:
EditText1.Initialize("EditText1")
EditText1.Wrap = True
EditText1.SingleLine = False
EditText1.InputType = EditText1.INPUT_TYPE_NONE

Interestingly, all contents in my string will line up to only one line, despite the fact that I already defined my EditText as Wrap = True and SingleLine = False.

For Example, it will display like this (wrong):

"AppleBananasMangoWatermelonChili"

Instead of (correct):

"Apple"
"Bananas"
"Mango"
"Watermelon"
"Chili"

What happens to this line of code (inputtext)? This is a bug or I am doing something wrong (I believe the second case is correct :D)? I am using the latest version of B4Android.

Thank you.
 
Last edited:

mangojack

Well-Known Member
Licensed User
Longtime User
Hi ... Try

B4X:
EditText1.Text = "Apple" & Chr(13) & Chr(10) & " Bananas"

chr(13) Carriage Return and chr(10) Line Feed ....

You could neaten it up with ...

B4X:
Dim line As String
   line = Chr(13) & Chr(10)
   
   EditText1.Text = "Apple" & line & " Bananas"

Cheers mj
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
If you enter "AppleBananasMangoWatermelonChili" it will show only in one line the string is ONE word !
If you enter "Apple Bananas Mango Watermelon Chili" it will work here you have several words.

@mangojack
In Android Chr(13) is not needed Chr(10) is enough.
Windows needs both.

Best regards.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Klaus ,Thanks for clearing that up .. I had code that would not work with just chr(13) so was including the LF(10) and all was well thinking you needed both , not realizing chr(10) would have done on its own.

Cheers mj
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
@klaus and mangojack

Thank you very much for your quick reply and advice.

But you don't correctly understand my question. Please download my attached test project (I attached new version here) and you will understand what I mean.

My string cannot be predicted, it is a kind of extract from an sms so it can be whatever the sms sender wrote, and may contain all: CRLF, Chr(13) and Chr(10)

In the project it shows you that edittext with EditText1.INPUT_TYPE_NONE will display the contents incorrectly (regardless whatever character I used Chr(10) as per your advice, or CRLF)... The second edittext without this code will display normally.
 

Attachments

  • TestEditText.zip
    7.1 KB · Views: 212
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
You must put : EditText1.InputType = EditText1.INPUT_TYPE_NONE
before the two following lines.
B4X:
EditText1.InputType = EditText1.INPUT_TYPE_NONE
EditText1.Wrap = True
EditText1.SingleLine = False
Then it works with Chr(13), Chr(10) and also spaces between the words i :
B4X:
Sub Button1_Click
'    Dim mytext As String = "Apple" & Chr(13) & "Bananas" & CRLF & "Mango" & Chr(13) & "Watermelon" & CRLF & "Chili"
    Dim mytext As String = "Apple Bananas Mango Watermelon Chili"
    Msgbox(mytext, "This is the string")
    EditText1.Text = mytext
End Sub
Just to clarify CRLF = Chr(10) in B4A !

Best regards.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
It is clear now, I forgot the order... :eek:

Many thanks Klaus for your time and help.

Best
 
Upvote 0

Roger Garstang

Well-Known Member
Licensed User
Longtime User
It isn't really an order problem, but a removal of the Multiline bits (131072). B4A sets/Ors your InputType to them when you set SingleLine to False. Then you are later replacing the InputType that contains MultiLine with INPUT_TYPE_NONE (0). You can also Or the Multiline bits with INPUT_TYPE_NONE to not clear them out.

If it is just showing data and the user has no need for selecting it to copy and paste you may want to just use a label. There are ways in Android to still show the keyboard by holding menu or holding on the EditText to get a menu to popup with options to select the keyboard and such. There are also ways to make it read only and remove the ability for it to get focus, but in the end you end up with something that behaves just like a Label. EditText also inherits from Label, so has much of the same functionality.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
It isn't really an order problem, but a removal of the Multiline bits (131072). B4A sets/Ors your InputType to them when you set SingleLine to False. Then you are later replacing the InputType that contains MultiLine with INPUT_TYPE_NONE (0). You can also Or the Multiline bits with INPUT_TYPE_NONE to not clear them out.

If it is just showing data and the user has no need for selecting it to copy and paste you may want to just use a label. There are ways in Android to still show the keyboard by holding menu or holding on the EditText to get a menu to popup with options to select the keyboard and such. There are also ways to make it read only and remove the ability for it to get focus, but in the end you end up with something that behaves just like a Label. EditText also inherits from Label, so has much of the same functionality.

Hi Roger,

Sorry for having overlooked your post. I was busy in the last 2 - 3 weeks.
Thanks for sharing your experience and time. Yes I agree with you.

I am working with a sms software where I receive the sms body and pass it to the label/edit text and I really face a big issue with this Multiline bits (131072)

Just a newbie question, then how can we do the removal of Multiline bits (131072), I tried several ways with Chr(10), Chr(13) etc... but no success.

Thank you again.
 
Upvote 0
Top