public boolean onOptionItemSelected(MenuItem item){
return super.onOptionsItemSelected(item);
}
Yes , java syntax is a little rusty, you ask, why should call the parent class ? Why do not you call your own ?
------ Solution ---------------------------------------- ----
parent class this method has achieved what we need to function , these functions may be that our own can not be achieved . Like the back button callback function , the callback you override the time, if you only want him to have a new feature , want to be able to achieve returns . For example, we want to press the back key to exit the program, you are prompted to quit before the launch , we have to call the parent class's back button callback , that is, through the super keyword call the parent class method , so as to achieve the return of function, and our newly added feature is a pop-up prompt dialog box . Here , back button to return to the function is not a simple software programming , but also to the hardware circuit response is more difficult to achieve. This is why you want to use the super keyword to call the parent class method causes.
------ eference --------------------------------------- < br> inherited from the parent class , you can call the parent class with a super way to realize the function of the parent class method , like adding your own methods to achieve
------ eference ------------------------------------ ---
possible parent class method implements some basic operations necessary subclasses do is based on these basic operations to implement other functions
------ eference ------ ---------------------------------
Thank you . Probably understand.
------ eference --------------------------------------- < br> I am a novice I think weak weak to ask a parent class that I inherited , and that I do not have the function of a parent class why it is called once
------ eference -------- -------------------------------
found that many times , the parent class method turned out to be abstract , there is no concrete realization . In the sub-class call inside super, I do not know where to call to achieve ?
very strange java
没有评论:
发表评论