1

I have an object mPhotoView which is declared and defined in a class (outer class?) CrimeFragment. I want to access a variable defined in a method of method of mPhotoView.

mPhotoView = (ImageView)v.findViewById(R.id.crime_photo);
    mPhotoView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int thumbnailHeight = mPhotoView.getHeight();
            int thumbnailWidth =  mPhotoView.getWidth();
        }
    });
    updatePhotoView(thumbnailHeight, thumbnailWidth); // shows error here. 

How do I achieve this?

(I tried declaring the variables as static/final and tried using this/super randomly. I do not understand the basics clearly.)

Aravind Varma
  • 38
  • 1
  • 6
  • Where is updatephotview defined? Cant you move that function call inside your ongloballayout function – lyncx May 10 '21 at 05:56
  • It is defined as one of the methods of CrimeFragment. It is being used somewhere else, so can't move it inside ongloballayout function – Aravind Varma May 10 '21 at 15:57

0 Answers0