I want to capitilze every word in edit text while typing.
My XML:-
<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"
                />
Now I am using
mName.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
But problem is it is not working in some device. Ex LG tablet. So I decided to do this programatically.
So I am using following codes.
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 > 0) {
                        for (int i = 0; i < strArray.length; i++) {
                            finalStr+=capitalize(strArray[i]);
                        }
                        Logger.d("finalStr==> ", finalStr);
                    }
                }
                mName.setText(finalStr.toString());
            }
private String capitalize(final String line) {
        return Character.toUpperCase(line.charAt(0)) + line.substring(1);
    }
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.
 
     
     
     
     
     
     
    