Android Question ViewsEx or XUI Views and Sender(solved)

Pedro Hu

Member
I am using the ViewEX library and the FloatLabeledEditText view.
I get this error:
simuladorno_isred1validar_textchanged (java line: 1508)
java.lang.ClassCastException: android.widget.EditText cannot be cast to com.wrapp.floatlabelededittext.FloatLabeledEditText
How can i fix this?
I have an error trying to use this code:
B4X:
Sub IsrED1Validar_TextChanged (Old As String, New As String)
    Dim b As FloatLabeledEditText
    b = Sender
End Sub [/ CODE]
 

Star-Dust

Expert
Licensed User
Longtime User
The event is raised by the EditText contained within the custom view then
B4X:
Sub IsrED1Validar_TextChanged (Old As String, New As String)
    Dim b As EditText
    b = Sender
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
There isn't a single reason to use FloatLabeledEditText. Less powerful, not cross platform and cannot be extended.
Why not point the OP to the correct solution?
From the question I did not intend that he wanted to build a multiplatform or that he wanted to extend functions and methods.

I simply answered the question he asked, then I could have given the suggestion to switch to the XUI views, but you had already suggested it so it was superfluous.

In my opinion, answering the first question directly is useful. There are those who want to use a single platform view or an older view for their evaluations. By giving him the answer and the suggestion, I give him the opportunity to choose.
Not giving the direct answer to the question but only the suggestion to switch to XUI in that way I force him to do it because I don't give him other ways
 
Upvote 0

Pedro Hu

Member
[QUOTE = "Star-Dust, publicación: 746864, miembro: 101440"]
El evento es creativo por EditText contenido en la vista personalizada y luego
[CÓDIGO = b4x] Sub IsrED1Validar_TextChanged (antiguo como cadena, nuevo como cadena)
Dim b As EditText
b = remitente
End Sub [/ CODE]
[/ CITAR]
If I do this it would no longer be using the FloatLabeledEditText wrapper and I would be using the properties of the eddittext, so this would no longer serve me.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
In my opinion, answering the first question directly is useful. There are those who want to use a single platform view or an older view for their evaluations. By giving him the answer and the suggestion, I give him the opportunity to choose.
Not giving the direct answer to the question but only the suggestion to switch to XUi in that way I force him to do it because I don't give him other ways
I agree and actually do it in many cases, however in this case there is really not a single reason to use the old wrapped view. It is not like ListView vs. xCLV where ListView is a reasonable choice in some cases.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
[QUOTE = "Star-Dust, publicación: 746864, miembro: 101440"]
El evento es creativo por EditText contenido en la vista personalizada y luego
[CÓDIGO = b4x] Sub IsrED1Validar_TextChanged (antiguo como cadena, nuevo como cadena)
Dim b As EditText
b = remitente
End Sub [/ CODE]
[/ CITAR]
If I do this it would no longer be using the FloatLabeledEditText wrapper and I would be using the properties of the eddittext, so this would no longer serve me.
No, your personalized view doesn't change. The sender is a simple EditText internal to the FloatLabeledEditText .

If then you need to recall the personalized view is another matter. You have to use another method than the sender.
 
Upvote 0

Pedro Hu

Member
No, your personalized view doesn't change. The sender is a simple EditText internal to the FloatLabeledEditText .

If then you need to recall the personalized view is another matter. You have to use another method than the sender.

I see, what I need is to retrieve the custom view, is there a way to do this or is it easier to do this with the XUI view ?, forgive me ignorance.
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
For both solutions, the class instance is set to the base panel Tag property.

From the sender go back to the base panel of the view, and retrieve the class instance from the Tag.

I seem to have read that for the XUI views (at least for some but I don't remember which one) Erel, has already make so that on the Tag you will find the link to the CustomView.

Otherwise you create it:
B4X:
FloatTextField.Tag=FloatTextField

B4X:
Sub CustomFloating_TextChanged (Old As String, New As String)
    Dim b As EditText = sender
    Dim PanelFloating as Panel = b.Parent
    Dim Floating as FloatLabeledEditText = PanelFloating.Tag
    'Dim Floating as B4XFloatTextField = PanelFloating.Tag
End Sub

In general it is so .... Try it, maybe you will have to make some corrections to the code, it is only an indication I have not tried it
 
Last edited:
Upvote 0

Biswajit

Active Member
Licensed User
Longtime User
I am using the ViewEX library and the FloatLabeledEditText view.
I get this error:
simuladorno_isred1validar_textchanged (java line: 1508)
java.lang.ClassCastException: android.widget.EditText cannot be cast to com.wrapp.floatlabelededittext.FloatLabeledEditText
How can i fix this?
I have an error trying to use this code:
B4X:
Sub IsrED1Validar_TextChanged (Old As String, New As String)
    Dim b As FloatLabeledEditText
    b = Sender
End Sub [/ CODE]
As its a custom view you have to create a layout file for FloatLabeledEditText and load it. So declare that view in the global sub,
B4X:
Sub Globals
    Dim IsrED1Validar as FloatLabeledEditText
End Sub
And on TextChanged event just use that declared view,
B4X:
Sub IsrED1Validar_TextChanged (Old As String, New As String)
    IsrED1Validar.visible = false 'or something else you want
End Sub
 
Upvote 0

Pedro Hu

Member
[QUOTE = "Star-Dust, publicación: 746891, miembro: 101440"]
Para ambas soluciones, la instancia de clase se establece en la propiedad Tag del panel base.

Desde el remitente, regrese al panel base de la vista y recupere la instancia de clase de la etiqueta.

Parece que he leído eso para las vistas XUI (al menos para algunas, pero no recuerdo cuál) Erel, ya se ha cansado, por lo que en la etiqueta encontrará el enlace a CustomView.

De lo contrario, lo creas:
[CÓDIGO = b4x] FloatLa LabelEditText.Tag = FloatLa LabelEditText [/ CODE]

[CÓDIGO = b4x] Sub CustomFloating_TextChanged (antiguo como cadena, nuevo como cadena)
Dim b As EditText = remitente
Dim Panel Flotante como Panel = b.
Dim flotante como FloatingLabelEditText = PanelFloating.Tag
End Sub [/ CODE]

En general es así ... Pruébalo, tal vez tendrás que hacer algunas correcciones al código, es solo una indicación de que no lo he probado
[/CITAR]

Thanks for the information, I will be checking it.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Pedro Hu

Member
Last edited:
Upvote 0

Pedro Hu

Member
Yes. It is explained here: [B4X] How to get <custom view here> from <CLV or any other container>

B4X:
Dim x As B4XView = Sender
Dim TextField As B4XFloatTextField = x.Tag
it worked by removing the B4XView to B4XFloatTextField
B4X:
Dim x As B4XFloatTextField = Sender
also, in the activity_resume I have an activity_create (true) and having this gives me an error and I don't understand why it happens

I know this is not from the thread but I have not looked for a way to change the color of the underline, is there a thread where they explain this?
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
it worked by removing the B4XView to B4XFloatTextField
You are correct. My mistake.

You should never call Activity_Create yourself. Tip: switch to B4XPages. Everything will be simpler.

I know this is not from the thread but I have not looked for a way to change the color of the underline, is there a thread where they explain this?
Pass B4XFloatTextField1.TextField. For further discussion please start a new thread.
 
Upvote 0
Top