How does this android Code work - "this" is being referenced in a static way(by the class name) in makeText method. ( 1st Parameter)
public class QuizActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
private Button mTrueButton;
mTrueButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(QuizActivity.this,R.string.incorrect_toast,Toast.LENGTH_SHORT).show();
}
});
}
}
The question is about how does "qualified this" work and not why does it exist or its purpose, but about how is "classname.this" being internally resolved to the enclosing object reference?Classname.this is usually used and works for static members , it shouldn't conceptually work for member variables like "this"; unless made to work that way