Auto remove leading space of any text of EditText?

后端 未结 4 1476
灰色年华
灰色年华 2021-01-16 07:21

Description

I am developing one app in which I have registration page. Inside registration page, I am doing registration by getting user\'s full nam

4条回答
  •  日久生厌
    2021-01-16 08:00

    Try this, check if start == 0, it will not allow user to add spaces before name

    @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                if(start == 0 && s.toString().contains(" ")){
                    user_name.setText("");
                }
            }
    

提交回复
热议问题