Android Question Input Type in B4x

stevenindon

Active Member
Licensed User
Hello all, I have been writing below for B4A and now i have to convert everything to B4X (Multiplatform for both B4A and B4i) :

B4X:
 Select Case iType
            Case "TEXT"
                sEditTxt(iIndex).InputType=sEditTxt(iIndex).INPUT_TYPE_TEXT
            Case "TEXTCAPITALISE"
                sEditTxt(iIndex).InputType=0x00082000 'DISABLE SPELL CHECK & AUTO CAPITAL
            Case "EMAIL"
                sEditTxt(iIndex).InputType=0x00080020 'DISABLE SPELL CHECK & EMAIL
            Case "NUMBER"
                sEditTxt(iIndex).InputType=sEditTxt(iIndex).INPUT_TYPE_NUMBERS
            Case "PHONE"
                sEditTxt(iIndex).InputType=sEditTxt(iIndex).INPUT_TYPE_PHONE
            Case "PASSWORD"
                sEditTxt(iIndex).InputType=0x00080000 'DISABLE SPELL CHECK
                sEditTxt(iIndex).PasswordMode=True
        End Select

Questions :

1) Are there anything like this in B4XView? I can convert sEditTxt(iIndex) to B4xview
2) If there is nothing like this in B4xview then how do i do the same to B4i?
* In B4i i noticed there is .TYPE_EMAIL_ADDRESS / .TYPE_NUMBER_PAD/ ... etc but i dont know how to set it ( MyTextField.InputType=MyTextField.TYPE_EMAIL_ADDRESS ) <<--- ERROR *No InputType

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can always set the type to B4XView and cast to the platform specific view when needed:
B4X:
#if B4A
YourView.As(EditText).InputType = YourView.As(EditText).INPUT_TYPE_NUMBERS
#end if

In this case it will be simpler to use B4XFloatTextField from XUI Views and set the settings with the designer. It is cross platform and supports most of the features.
 
Upvote 0

stevenindon

Active Member
Licensed User
Thank you Erel. The above code is applicable for B4A. What about B4i?


B4X:
#if B4A
YourView.As(EditText).InputType = YourView.As(EditText).INPUT_TYPE_NUMBERS
#if B4i
YourView.As(TextField).InputType = YourView.As(TextField).INPUT_TYPE_NUMBERS  <<---???
#end if

This wont work in B4i compiler
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are not using the conditional compiling correctly.
if b4i is inside the if b4a block.

B4X:
#If B4A
'Do something
#Else If B4i
'...
#Else
'...
#End If
 
Upvote 0

stevenindon

Active Member
Licensed User
Thank you for the highlight DonManfred. My typo error in this forum. Suppose to be :

B4X:
#if B4A
YourView.As(EditText).InputType = YourView.As(EditText).INPUT_TYPE_NUMBERS
#else if B4i
YourView.As(TextField).InputType = YourView.As(TextField).INPUT_TYPE_NUMBERS  <<---???
#end if

May i knw how can i set INPUT_TYPE_NUMBERS for TextField in B4i?

Sorry and thanks
 
Upvote 0
Top