java - Determine how many times IME_ACTION_GO is pressed -


I am trying to run a method when the login button is pressed 1 time.

If it is pressed 2 or more times, I do not want to run the method, and I want to do RawInputType and / or IMEOptions To return to the normal button functionality, go back.

How do I get this function?

My code so far

  public int press = 0; BodyText.setRawInputType (InputType.TYPE_CLASS_TEXT); BodyText.setImeOptions (KeyEvent.KEYCODE_ENTER); BodyText.setOnEditorActionListener (New TextView.OnEditorActionListener) {Public Boolean onEditorAction (TextView V, Integer actionId, KeyEvent event) {if (actionId == KeyEvent.KEYCODE_ENTER} {if (press == 0) {press + = 1; // Play "method"} if (press & gt; = 1) {// "never run" method} back true;} return false;}});    

It seems that your code is almost but it seems that you are not returning right What is the matter, which is consuming this phenomenon, which means that the default functionality will not run after press 0.

You will only want to return when pressed == 0, something with the line:

  if (press == 0) {// Run method here is true ; } Else {// Return to indicate that the event was not used so that the default // behavior is executed. return false; }  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -