OnEditorActionListener called twice with same eventTime on SenseUI keyboard
Posted
by
ydant
on Stack Overflow
See other posts from Stack Overflow
or by ydant
Published on 2010-11-03T14:06:23Z
Indexed on
2011/01/10
23:53 UTC
Read the original article
Hit count: 156
android
On just one phone I am testing on (HTC Incredible, Android 2.2, Software 3.21.605.1), I am experiencing the following behavior.
The onEditorAction event handler is being called twice (immediately) when the Enter key on the Sense UI keyboard is pressed.
The KeyEvent.getEventTime() is the same for both times the event is called, leading me to this work-around:
protected void onCreate(Bundle savedInstanceState) {
[...]
EditText text = (EditText)findViewById(R.id.txtBox);
text.setOnEditorActionListener(new OnEditorActionListener() {
private long lastCalled = -1;
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if ( event.getEventTime() == lastCalled ) {
return false;
} else {
lastCalled = event.getEventTime();
handleNextButton(v);
return true;
}
}
});
[...]
}
The EditText is defined as:
<EditText
android:layout_width="150sp"
android:layout_height="wrap_content"
android:id="@+id/txtBox"
android:imeOptions="actionNext"
android:capitalize="characters"
android:singleLine="true"
android:inputType="textVisiblePassword|textCapCharacters|textNoSuggestions"
android:autoText="false"
android:editable="true"
android:maxLength="6"
/>
On all other devices I've tested on, the action button is properly labeled "Next" and the event is only called a single time when that button is pressed.
Is this a bug in Sense UI's keyboard, or am I doing something incorrectly?
Thank you for any assistance.
© Stack Overflow or respective owner