使用該部分設備的鍵盤不支持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
txtAllCaps和textCapWords是不同的東西 –
textCapCharacters在Android 7三星鍵盤上停止工作。所以你從我那裏得到一個投票,即使不是所要求的:) – Moth