title: Capitalize every word in Edit text while typing
body: <p>I want to capitilze every word in edit text while typing.</p>
  
  <p>My XML:-</p>
  
  <pre><code>&lt;com.project.edittext.AutoFitEditText
                  android:id="@+id/txt_name"
                  style="@style/scan_text_fields_white_bg"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:digits="@string/validation_accept_all_except_special_char"
                  android:fontFamily="sans-serif"
                  android:imeOptions="flagNoExtractUi|actionDone"
                  android:inputType="textNoSuggestions|textCapWords"
                  android:maxLength="50"
                  android:paddingBottom="3dp"
                  android:paddingLeft="12dp"
                  android:paddingRight="0dp"
                  android:paddingTop="0dp"
                  android:singleLine="true"
                  android:textColor="@color/orange"
                  /&gt;
  </code></pre>
  
  <p>Now I am using </p>
  
  <pre><code>mName.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
  </code></pre>
  
  <p><strong>But problem is it is not working in some device. Ex LG tablet. So I decided to do this programatically.</strong></p>
  
  <p>So I am using following codes.</p>
  
  <pre><code>public void onTextChanged(CharSequence s, int start, int before, int count) {
                  // TODO Auto-generated method stub                   
                  String mNameStr=s.toString();
                  String finalStr="";
                  if(!mNameStr.equals("")) {
                      String[] strArray = mNameStr.split("[\\s']");
                      if (strArray.length &gt; 0) {
                          for (int i = 0; i &lt; strArray.length; i++) {
                              finalStr+=capitalize(strArray[i]);
                          }
                          Logger.d("finalStr==&gt; ", finalStr);
                      }
                  }
                  mName.setText(finalStr.toString());
              }
  
  
  
  private String capitalize(final String line) {
          return Character.toUpperCase(line.charAt(0)) + line.substring(1);
      }
  </code></pre>
  
  <p>Here my app getting crash. I found the problem while debugging. Problem is the onTextChanged is not getting stopped. So that it execute continuously. Anyone help me to resolve my problem. I want to capitalize every word. Please suggest any solutions. </p>