views:

87

answers:

1

I have a class defined as

public class viewGroups extends ListActivity

Somewhere in the class I have

objItem = new clsContactGroups(context);

I am wondering what is advised to be used here? Which context? I know four choices, but maybe there are others...

this
this.getApplicationContext()
this.getBaseContext()
this.getParent()

I use this Context to show a Toast. So I would like to show on the front-most view visible.

+2  A: 

Use this. The toast will be associated with your ListActiviy, which is what you are looking for. The ApplicationContext is not suitable (I'm not sure what would happen) and I think the getBaseContext() is probably going to return the same as the Application Context. getParent() would be a good choice if your activity is embedded in another, but this should be rare.

Segfault