Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can add a TextWatcher to an <code>EditText</code> and get notified each time the text is notified. Using that, you can just parse the String to find the characters after a space, and update them to uppercase. </p> <p>Here's a quick test I made which works pretty well (far from optimal, because each time you edit the Editable it calls the listener again...).</p> <pre><code> editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { String string = s.toString(); int index = -1; while (((index = string.indexOf(' ', index + 1)) != -1) &amp;&amp; (index + 1 &lt; string.length())) { // Get character char c = string.charAt(index + 1); if (Character.isLowerCase(c)) { // Replace in editable by uppercase version s.replace(index+1, index + 2, Character.toString(c).toUpperCase()); } } } }); </code></pre> <p>To avoid being called to often, you could make all the changes in a <code>char[]</code> and only commit to the <code>Editable</code> if changes were made.</p> <p>A simpler solution is probably to just use <code>split(' ')</code> on your String, replace all first letters in the <code>String[]</code> by the uppercase version (if needed), and commit only once to the <code>Editable</code>.</p> <p>A simpler optimisation would be to add a boolean to your anonymous class, set it to try when you enter afterTextChanged, set it back to false when you exit it, and only process the string if the boolean is false. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload