Thursday, 3 October 2013

Java - Reference outer class from handlers

Java - Reference outer class from handlers

I have the following code
this.spin.setOnItemSelectedListener( new
AdapterView.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View arg1, int
arg2,long arg3){
Gradebook.this.pd =
ProgressDialog.show((Context)Gradebook.this, (CharSequence)"",
(CharSequence)"Loading Grade Book...", true, true);
Gradebook.this.gradecatitems.clear();
new Thread(new Runnable() {
public void run() {
//I need to reference the top-most
level class, GradeBook's members in
here
}
}).start();
});
How do I reference the top-level class member from within my Thread? Keep
in mind that my thread is an anonymous class already within an anonymous
class.

No comments:

Post a Comment