Reputation: 3807
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?
Upvotes: 1
Views: 181
Reputation: 6555
YourActivityName.this
, or perhaps YourClassName.this
. Last one is untested, and I don't have Android's SDK here to test.
Upvotes: 1