1
votes

I want two image view on one activity view, One image for profile picture and other for profile cover page.

My code


    setupImage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  bringImagePicker();
                }
    });

    private void bringImagePicker() {
            // start picker to get image for cropping and then use the image in cropping activity
            CropImage.activity()
                    .setGuidelines(CropImageView.Guidelines.ON)
                    .setAspectRatio(1,1)
                    .start(SetupActivity.this);
        }


    @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);

            if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
                CropImage.ActivityResult result = CropImage.getActivityResult(data);
                if (resultCode == RESULT_OK) {
                    mainImageURI = result.getUri();
                    setupImage.setImageURI(mainImageURI);
                    isChanged = true;
                } else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
                    Exception error = result.getError();
                }
            }

        }

Now how can I add for profile cover image??

1
profileImg.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bringImagePickerCoverImg(); } }); but it replace old image not set to profile cover image viewSarfaraz

1 Answers

1
votes

You can use ID for both of them, and change the image with corresponding ID from the intent that holds data, add another condition after receiving the results. I don't know if this library can handle this or not. If not this simplest solution to hold state variable that tells you which image to update feel free to ask for clarification