1

I have the following code and i am unable to change my imageview resource in my program . I have a similar code in another fragment of my program and it works perfectly. I have tried to clean build my project as suggested by other posting.

I tried both

status.setImageDrawable(getResources().getDrawable(R.drawable.login_tick)); status.setImageResource(R.drawable.login_cross);

@Override
public void onActivityCreated (Bundle savedInstanceState)
{
    super.onActivityCreated(savedInstanceState);

    status = (ImageView)getActivity().findViewById(R.id.um_namestatus);
    registerButton = (Button) getActivity().findViewById(R.id.um_registerButton);

    name = (EditText) getActivity().findViewById(R.id.um_name);

    name.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                status.setImageDrawable(getResources().getDrawable(R.drawable.login_tick)); 
                test();
            }
        }
    });
}

protected void test() {
    // TODO Auto-generated method stub
    status.setImageResource(R.drawable.circle_green);
    Toast.makeText(getActivity(), "" + "//////",Toast.LENGTH_SHORT).show();
}
4

0 回答 0