B4J Question Set TextField alignment in B4J

Armando Barrera

Member
Licensed User
Longtime User
Hi everyone,

I am trying to set the alignment for some TextFields (mainly, to right for numbers), I've been searching in the forum before i create this question, but could not fix my issue.
Unfortunaly i din't catch the solutions. If someone knows how can i fix it, I would be very grateful.
If more information is needed, please let me know.

Best regards

Armando Barrera
 

thinktank

Member
Try this

Set Alignment of Textfield:
        Dim lbl As Label
        lbl.Initialize("")
        
        Dim jo As JavaObject = lbl
        jo.RunMethod("setTextAlignment", Array("RIGHT"))
 
Upvote 0

Armando Barrera

Member
Licensed User
Longtime User
B4X:
MyTextField.As(JavaObject).RunMethod("setAlignment", Array("CENTER_RIGHT"))

Should work.

T.
Hi Tomar,

Thanks for your quick response, but I'am afraid that I don't know how to adapt it for my matter, i received the next error message:

Main - 914: Variable 'javaobject' no declarada se utiliza antes de que se le haya asignado cualquier valor.

And in the line:
TextField1.As(JavaObject).RunMethod("setAlignment", Array("CENTER_RIGHT"))

the word JavaObject became red.
And don´t know what to do next.

I appreciate your support, thank you very much


TextField Testing:
Sub Button1_Click
    
    Dim lbl As Label
    lbl.Initialize("")
        
    Dim jo As JavaObject = lbl
    jo.RunMethod("setTextAlignment", Array("RIGHT"))
    
    
    TextField1.As(JavaObject).RunMethod("setAlignment", Array("CENTER_RIGHT"))
    
End Sub
 
Upvote 0

Armando Barrera

Member
Licensed User
Longtime User
1. Make sure to use latest version of B4J.
2. You can set the alignment of TextField with the designer or programmatically with the same API as Label or B4XView.
Hi Erel,

I do not have the B4J latest version. I haven't updated due to my concern that my program is affected, but i will do it.
Appreciate your quick support as well, and let you both know the result.

Thank you very much
 
Upvote 0

Armando Barrera

Member
Licensed User
Longtime User
Hi mcqueccu,

I have it ticked but with version 2.06, may be that´s the problem.
As said to Erel, i'll update the B4J with latest version (9.5) in fact have the version 8.50.

Thank you very much for your support.
 
Upvote 0

Armando Barrera

Member
Licensed User
Longtime User
Hi everyone,
I've just installed the new version (9.50), my issue is fixed, now i can set the TextField alignment by using the designer.
Thank you all

Best regards
Armando Barrera González
 
Upvote 0
Top