我有一个在类(外部类?)CrimeFragment 中声明和定义的对象 mPhotoView。我想访问在 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.
我如何实现这一目标?
(我尝试将变量声明为 static/final 并尝试随机使用 this/super。我不太了解基础知识。)