1. 程式人生 > >Android 判斷Edittext是否有焦點

Android 判斷Edittext是否有焦點

 //判斷Edittext是否有焦點
        name.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if (b){
                Login_image_name.setImageDrawable(getResources().getDrawable((R.drawable.name_sel)));
                Login_image_password.setImageDrawable(getResources().getDrawable(R.drawable.password));
                }else{
                    Login_image_name.setImageDrawable(getResources().getDrawable((R.drawable.name)));
                    Login_image_password.setImageDrawable(getResources().getDrawable(R.drawable.password_sel));
                }

            }
        });