You can use a Textwatcher, as the user type you will check the size of the string, when you reach the length limit you change the focus to another edittext.
public class YourClass extends Activity {
private EditText yourEditText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
yourEditText = (EditText) findViewById(R.id.yourEditTextId);
yourEditText.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
// you can call or do what you want with your EditText here
SE tamanho = tamanhoLimite ENTAO
muda o foco
FIMSE
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
}
}
You can take a look at this other topic here, which is where I took the code snippet above: https://stackoverflow.com/questions/11134144/android-edittext-onchange-listener
Basically as Carlos Rafael answered, but need to search the limit of editText to compare using the
lentgh()
.– rbz
https://stackoverflow.com/questions/8069015/how-to-get-edittext-maxlength-setting-in-code
– rbz