Android Question EditText EnterPressed event getting raised twice

Inman

Well-Known Member
Licensed User
Longtime User
I am using the following code to declare an EditText and display a Search icon instead of Done button
B4X:
    txtname.Initialize("txtname")
    txtname.Hint="Product"
    txtname.SingleLine=True
    
    Activity.AddView(txtname,10dip,lblline.Top+lblline.Height+5dip,100%x-20dip,48dip)
    Dim JO As JavaObject = txtname
    JO.RunMethod("setImeOptions",Array As Object(3))

Now to capture search button
B4X:
Sub txtname_EnterPressed
    Log(txtname.Text)
End Sub

Problem is every time I type something into the textbox and hit search icon on keyboard, the log prints it twice. Which means the EnterPressed event is getting raised twice. If I remove the javaobject code that shows search icon, EnterPressed works fine as it gets raised only once. But if I display search icon, the event is raised twice.

Any idea how to fix this?
 

Inman

Well-Known Member
Licensed User
Longtime User
I will try to upload over the weekend. Fortunately the client's requirement changed and so displaying search icon is no longer needed.
 
Upvote 0
Top