java - automatically separate mm:ss in editText? -


I would like the user to input a few minutes and a second at a time after input of the input I will automatically create a " : "How do I add?

Use of Eclipse with Java.

So far I have this:

  EditText editTextT; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_main); EditTextT = (Editing Text) SearchVBIID (RIDE Identity); editTextT.setOnKeyListener (New EditText.OnKeyListener) {Public Boolean ON (see V, Int kikod, Key Event Event) {if (editTextT.getText (). length () == 2) {editTextT.setText (editTextT.getText () + ":"); EditTextT.setSelection (editTextT.getText (). Length ());} return false;}});    

You have to add KeyListener to your TextField . Then for example you can respond to a key that is released. You check the text for length in your text and add a : at the end of the string.
Take a look at this:

  Textfield addKeyListener (New KeyListener) {@Override public void keyTyped (KeyEvent e) @} Override public zero key is pressed (keyEvent e) {} @ Override Public Zero Key Relay (KeyEvent E) {If (textfield.getText (). Length () == 2} {textfield.setText (textfield.getText () + ":"); Textfield.Setcertation (Textfield. Gate text) (length) ());}}});  Edit:  This is the solution for Java as mentioned above, if you need a solution for Android (your  editText ), Try it:  
  edittext.addTextChangedListener (new textvotter () {@ override public after zero text (editable) {if (editText.getText (). Length () == 2) {editText.setText (editText.getText) (editText.getText () + editText.setSelection (et.getText). Length ());}} @TranslatedChanged (first of int, int int, int count, int Zero override) {} bit on @TextChanged Override public zeros (edit the initials, int before, int count) {}}   

Edit 2: Please check the update and try it With a TextWatcher.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -