程序中的edittext只接受数字。默认设置为0。我想输入数字后覆盖初始值0。现在问题是,比如当我输入数字1,出现的是01,我希望edittext中显示1而不是01。代码如下:
value = (EditText)findViewById(R.id.value);
value.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{
if(arg0.length()==0)
{
value.setText("0");
int i = value.getText().length();
value.setSelection(i);
}
}
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
}
public void afterTextChanged(Editable arg0) {
}
}
请求大家的帮忙,看问题出在哪里?