프로그래밍 정리/안드로이드

[안드로이드] EditText 해당글자수 입력시 자동으로 다음 EditText로 넘어가기

주누다 2012. 8. 16. 11:25
반응형

coupon_number1.addTextChangedListener(new TextWatcher() { 

       @Override

       public void onTextChanged(CharSequence s, int start, int before, int count) { 

        if(coupon_number1.getText().toString().length() == 4){

        coupon_number2.requestFocus();

        }

       } 

       @Override

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

       } 

       @Override

       public void afterTextChanged(Editable s) { 

       } 

    }); 

coupon_number2.addTextChangedListener(new TextWatcher() { 

       @Override

       public void onTextChanged(CharSequence s, int start, int before, int count) { 

        if(coupon_number2.getText().toString().length() == 4){

        coupon_number3.requestFocus();

        }

       } 

       @Override

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

       } 

       @Override

       public void afterTextChanged(Editable s) { 

       } 

    }); 

coupon_number3.addTextChangedListener(new TextWatcher() { 

       @Override

       public void onTextChanged(CharSequence s, int start, int before, int count) { 

        if(coupon_number3.getText().toString().length() == 4){

        coupon_number4.requestFocus();

        }

       } 

       @Override

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

       } 

       @Override

       public void afterTextChanged(Editable s) { 

       } 

    });

반응형