0

我有一个数字选择器,允许用户在固定范围内输入一些数字。

默认情况下,该数字不允许用户输入大于为数字选择器设置的最大值的数字。

但是,我想在发生这种情况时显示一条消息。有没有办法访问数字选择器中的编辑文本?谢谢。

4

1 回答 1

0

您可以实现 TextChangedListener,它将注册该字段中的每个更改,以便您可以对其采取相应措施。

例如。

 yourEditText = (EditText) findViewById(R.id.yourEditTextId);

    yourEditText.addTextChangedListener(new TextWatcher() {

      public void afterTextChanged(Editable s) {

        // you can call or do what you want with your EditText here
        yourEditText. ... 

      }

      public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

      public void onTextChanged(CharSequence s, int start, int before, int count) {}
   });
于 2014-01-23T03:39:57.133 回答