I am using an Edit Text in my project.
The problem is that whenever I type anything into the text box, it shows up, but the cursor does not move from its starting po
I am using this workaround for this problem, If characters are in English or digit characters then change EditText gravity to left else in another Language in my case it's in Arabic then will change gravity to left and the cursor will move in it's right way according to each language:
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(s.length() > 0){
char c = s.charAt(0);
// characters are Enlgish or digits.
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || Character.isDigit(c)) {
editText.setGravity(Gravity.LEFT);
}else {
editText.setGravity(Gravity.RIGHT);
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});