Hello I'm trying to make a edit text with limit, I've successfully created it for alphabet but now I want to set different limit for japanese character and chinese character is it possible?
this is my code now
etComment = new EditText(context);
LayoutParams lpComment = new LayoutParams(
(Util.getDisplayWidth(context) * 3) / 5,
Util.getDisplayHeight(context) * 3 / 10);
etComment.setLayoutParams(lpComment);
if (BaseID.user_language == BaseID.LANGUANGE_JP) {
etComment.setHint(context.getResources().getString(
R.string.CommentHint_jp));
} else if (BaseID.user_language == BaseID.LANGUANGE_EN) {
etComment.setHint(context.getResources().getString(
R.string.CommentHint_en));
}
int maxLength = 10;
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(maxLength);
etComment.setFilters(FilterArray);
Right now for alphabet is 10 I want to limit for japanese character and chinese character only 5 how can I do it?
thank you
Try this thing
if (BaseID.user_language == BaseID.LANGUANGE_JP) {
maxLength = 10;
} else if (BaseID.user_language == BaseID.LANGUANGE_EN) {
maxLenght = 8;
}