문제

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; }

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top