skip to Main Content
    imageView1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view)
        {
            if(imageViewGet1.getDrawable() != null){
                imageView1.setVisibility(View.INVISIBLE);
                imageViewGet1.setVisibility(View.VISIBLE);
            }
            OpenGallery1();

        }
    });
    imageView2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view)
        {
            if(imageViewGet2.getDrawable() != null){
                imageView2.setVisibility(View.INVISIBLE);
                imageViewGet2.setVisibility(View.VISIBLE);
            }
            OpenGallery2();

        }
    });

when I run the code and open galley to pick new photo, after that, the imageView with the old one still appear
how I can fix that so when I choose new image, the imageView1 disappear and imageViewGet appear with the new Image.

2

Answers


  1. Chosen as BEST ANSWER

    I tried this :

    imageView1.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view)
                {
                    OpenGallery1();
    
                        imageView1.setVisibility(View.INVISIBLE);
                        imageViewGet1.setVisibility(View.VISIBLE);
                    if(imageViewGet1.getDrawable()==null){
                        imageView1.setVisibility(View.VISIBLE);
                    }
                }
            });
    

    and it works fine.


  2. try to use

    imageView1.setVisibility(View.GONE);
    

    if are views overlapping (one is in front of second).

    .setVisibility(View.INVISIBLE);
    

    just makes view invisible, but doesn’t hide it.

    If this won’t help, you may can use Shared Preferences to store bool with image (in)visibility state.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search