例如 在EditText输入框输入 123456789 就自动调整为 1234-4568-8889    谁知道怎么实现一边输入就一边调整  ,拜谢!   

解决方案 »

  1.   

    问题你要是使用 TextWatcher 肯定是进行setText()操作  如果这样的话那我就删除不了
    你有什么好的建议?
      

  2.   

    //限制两位小数
    txtMoney.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before,
    int count) { } public void beforeTextChanged(CharSequence s, int start, int count,
    int after) { } public void afterTextChanged(Editable s) {
    String temp = s.toString();
    int posDot = temp.indexOf(".");
    System.out.println(posDot);
    if (posDot <0)
    return;
    if(posDot==0)
    {
    s.clear();
    }
    if (temp.length() - posDot - 1 > 2) {
    s.delete(posDot + 3, posDot + 4);
    } }
    });这是我限制两位小数输入的方法,你看看有什么启发