XX_*_*her 4 android android-edittext
现在,我的EditText只能输入数字.但是我想禁止在零是第一个数字时输入零.我能怎么做?
这应该可以帮到你:
yourTextEdit.addTextChangedListener(new TextWatcher(){
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (yourTextEdit.getText().matches("^0") )
{
// Not allowed
yourTextEdit.setText("");
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void afterTextChanged(Editable s){}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3195 次 |
| 最近记录: |