2016-07-27 29 views
0

這是我的EditText,textCapWords不適用於三星鍵盤。 (三星S4)。有沒有解決方法?textCapWords不適用於三星鍵盤

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="16dp" 
     android:background="@android:color/transparent" 
     android:imeOptions="actionDone" 
     android:inputType="textCapWords" 
     android:maxLength="15" 
     android:padding="12dp" 
     android:textSize="20sp" /> 

回答

1

在XML試試這個:

android:textAllCaps="true" 
+1

txtAllCaps和textCapWords是不同的東西 –

+0

textCapCharacters在Android 7三星鍵盤上停止工作。所以你從我那裏得到一個投票,即使不是所要求的:) – Moth

0

使用該部分設備的鍵盤不支持capWords或禁止設置

該代碼EDITTEXT每個單詞的第一個字母大寫

youredittext.addTextChangedListener(new TextWatcher() { 
     @Override 
     public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { 

     } 

     @Override 
     public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { 

     } 

     @Override 
     public void afterTextChanged(Editable editable) { 
      String capitalizedText = WordUtils.capitalize(youredittext.getText().toString()); 
      if (!capitalizedText.equals(youredittext.getText().toString())) { 
       youredittext.addTextChangedListener(new TextWatcher() { 
        int mStart = 0; 
        @Override 
        public void beforeTextChanged(CharSequence s, int start, int count, int after) { 

        } 

        @Override 
        public void onTextChanged(CharSequence s, int start, int before, int count) { 
         mStart = start + count; 
        } 

        @Override 
        public void afterTextChanged(Editable s) { 
         youredittext.setSelection(mStart); 
         youredittext.removeTextChangedListener(this); 
        } 
       }); 
       youredittext.setText(capitalizedText); 
      } 
     } 
    }); 

下載JAR導入WordUtils

https://www.dropbox.com/s/olfjyhfrghxvfs2/orgwordutils.jar?dl=0

1

你嘗試編程?

youredttxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS); 

OR

android:inputType="textCapWords|textCapSentences" 

OR

AFAIK這一個已被棄用,但我不知道將它的工作或沒有,但你可以嘗試,

​​
0

可以試試這個...爲我工作...

android:inputType="textCapWords" 

或者

android:inputType="textCapSentences" 

或者

android:inputType="textCapWords" 

對於三星S5/S7有用於製作第一承租人的帽子在一個名爲 「自動大寫」 設置的其他設置。

相關問題