I have the following code:
public void setupScreen()
{
view.runOnUiThread(new Runnable()
{
public void run()
{
view.setContentView(R.layout.game);
LinearLayout layout = (LinearLayout)view.findViewById(R.id.game_layout);
ViewTreeObserver vto = layout.getViewTreeObserver();
vto.addOnGlobalLayoutListener(this);
}
});
}
This method is inside of a class that implements OnGlobalLayoutListener. I want to reference the class so i can put it as the parameter for the addOnGlobalLayoutListener() method. The problem is, is that when you reference this inside of a Runnable that is defined on the fly, this references the Runnable instead of the class I’m trying to reference. What is the work around for this?
did you try
NameOfYourClass.this?