Android Tutorial Similar to FloatLabeledEditText

Someone asked me to do something like FloatLabeledEditText.

I made this example. It is not identical, but it is a track or a point of partenzs for those who want to create a similar one
 

Attachments

  • LabelExtended.zip
    9.4 KB · Views: 738

Star-Dust

Expert
Licensed User
Longtime User
Inside there is the source code. You should try with the Accessibility library to get an overview of EditText.

But I think we can do it. At the moment I'm busy on another front :p
 

Star-Dust

Expert
Licensed User
Longtime User
In the class, add the declaration of events to the top of the code
B4X:
#Event: TextChanged (Old As String, New As String)
#Event: FocusChanged (HasFocus As Boolean)
#Event: EnterPressed

Edit the Sub TextChanged as shown below:
B4X:
Private Sub MyEditText_TextChanged (Old As String, New As String)
    HintAnimation(New.Length>0)
    If SubExists(mCallBack,mEventName & "_TextChanged") Then CallSub3(mCallBack,mEventName & "_TextChanged",Old,New)
End Sub

Add these two SUB
B4X:
Private Sub MyEditText_FocusChanged (HasFocus As Boolean)
    If SubExists(mCallBack,mEventName & "_FocusChanged") Then CallSub2(mCallBack,mEventName & "_FocusChanged",HasFocus)
End Sub

private Sub MyEditText_EnterPressed
    If SubExists(mCallBack,mEventName & "_EnterPressed") Then CallSub(mCallBack,mEventName & "_EnterPressed")
End Sub
 

M.LAZ

Active Member
Licensed User
Longtime User
thank you so much for reply ,, Grazie Mille

sorry , but it seems there is no top properties
B4X:
Sub txtCard_FocusChanged (HasFocus As Boolean)
    Dim Send As LabelExended '
        If HasFocus Then
        Send = Sender
        Log(Sender)
        SV.ScrollPosition = Send.Top - 20dip
    End If
End Sub
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
thank you so much for reply ,, Grazie Mille

sorry , but it seems there is no top properties
B4X:
Sub txtCard_FocusChanged (HasFocus As Boolean)
    Dim Send As LabelExended '
        If HasFocus Then
        Send = Sender
        Log(Sender)
        SV.ScrollPosition = Send.Top - 20dip
    End If
End Sub
I do not understand what you mean. Sorry
 

M.LAZ

Active Member
Licensed User
Longtime User
There is a quite powerful and cross platform implementation of a float labeled text field in XUI Views.

yes i know , but in FloatLabeledEditText i can't set the right gravity property for the Hint especially during typing in Edittext and there is no animation for hint.
 

Star-Dust

Expert
Licensed User
Longtime User
I do not understand what you mean. Sorry
 
Top