I have an array of editTexts which I make like this:
inputs[i] = new EditText(this);
inputs[i].setWidth(376);
inputs[i].setInputType(
Just use String.toUpperCase()
method.
example :
String str = "blablabla";
editText.setText(str.toUpperCase()); // it will give : BLABLABLA
EDIT :
add this attribute to you EditText
Tag in your layout
xml :
android:textAllCaps="true"
OR:
If you want whatever the user types to be uppercase you could implement a TextWatcher
and use the EditText
addTextChangedListener
to add it, an on the onTextChange
method take the user input and replace it with the same text in uppercase.
editText.addTextChangedListener(upperCaseTextWatcher);
final TextWatcher upperCaseTextWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editText.setText(editText.getText().toString().toUpperCase());
editText.setSelection(editText.getText().toString().length());
}
public void afterTextChanged(Editable editable) {
}
};