开发者

Android: reason for calling superclass?

开发者 https://www.devze.com 2023-03-26 04:14 出处:网络
I\'m looking at the Notepad tutorial from the Android developer\'s site. I have a question about overridden functions calling the super-class of activities. For example,

I'm looking at the Notepad tutorial from the Android developer's site. I have a question about overridden functions calling the super-class of activities. For example,

public class Notepadv3 extends ListActivity {
    ...

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(0, INSERT_ID, 0, R.string.menu_insert);
    return true;
    }
}

What's the point of the super.onCreateOptionsMenu()? I looked at the developer's site and found this explanation:

Call super.onCreateOptionsMenu(menu) so the original menu items are created, then a开发者_Go百科dd new menu items with menu.add().

But what original menu items are there?

Similarly, what's the point of other super.(overridden_function), such as super.onCreateContextMenu?


Activities have a number of operations they perform throughout their life cycle - some of these are house cleaning (garbage collection), UI stuff, etc.

As far as I know, super.onCreateContextMenu() doesn't have to be called, unlike methods like onCreate, onResume, etc.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号