Dim CurrencySymbol As String CurrencySymbol = "$" Sub EditText1_TextChanged (Old As String, New As String) If New.Length > 0 Then If Not(New.StartsWith(CurrencySymbol)) Then EditText1.Text = CurrencySymbol & EditText1.Text EditText1.SelectionStart = EditText1.Text.Length End If End If End Sub
Dim CurrencySymbol As String CurrencySymbol = "$"
Dim CurrencySymbol As String = "$"
Is it possible?Dim CurrencySymbol As String = "$"
I agree (of course )Modifying the text while the user changes it can result in a bad UX. For example if the user adds a character before the $ sign then it will add a new $ sign. I think that you will get better result if you add it when the focus is removed.
Sub EditTextSetup(EditTxt As EditText) 'Create a bitmap to draw on Dim BMP As Bitmap BMP.InitializeMutable(40dip,40dip) 'Create a Canvas and assign to the bitmap Dim C As Canvas C.Initialize2(BMP) C.DrawText("$",20,40,Typeface.DEFAULT,20,Colors.White,"CENTER") 'Convert the bitmap to a Drawable Dim BMD As BitmapDrawable BMD.Initialize(C.Bitmap) 'Add the image to the edit text Dim ETxt As JavaObject = EditTxt ETxt.RunMethod("setCompoundDrawablesWithIntrinsicBounds",Array As Object(BMD,Null,Null,Null)) End Sub