I am new to android and java and i can not get my head around understanding why in android "this" keyword is sometimes used and not "super"?
Also how can you call parent methods without "this" or "super" keyword.
For example lets say we have
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void sendMessage(View view) {
Intent intent = new Intent(this, DisplayMessageActivity.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
this.startActivity(intent);
}
We can see that in above example MainActivety class does not have setContentView method in fact this method is defined in ActionBarActivity as
public void setContentView(int layoutResID) {
this.getDelegate().setContentView(layoutResID);
}
So how are we able to call it without "this" or "super"?
Why does it still work if we would put "this" infront although the method is defined in parent class isnt "this" keyword meant for current scope/class.