public class NewPlanet extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
ImageView marsImage = (ImageView) findViewById(R.id.imageMars);
marsImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WorldGen mars = new WorldGen("Mars", 642, 3.7);
mars.setPlanetColonies(1);
Toast.makeText(NewPlanet.this, "Mars Created", Toast.LENGTH_SHORT).show();
}
});
}
}
What context does NewPlanet.this
reference? Why does makeText
from class Toast
need this context? I understand the use of keyword this
when referencing a class and using dot notation to access its fields and constructors as in this.field
, but what about when the this
keyword comes after a class reference?