Eclipse Shortcut for Android Lifecycle methods
Does the ADT introduces any shortcuts to create the life cycle methods using a keyboard shortcut, or is it necessary to create a code template to handle that job?
I know that it's possible to use Alt + Shift + S V but that is a huge list to pick from. I would just like to have all that are related to lifecycle
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate开发者_如何转开发(savedInstanceState);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
Upon extending the Activity
class, you can simply jump to a new line, type "oncr"
and press CTRL+space and the onCreate
method will pop up.
Similarly, simply typing "onpa"
on a new line and then pressing CTRL+space will provide you with the respective method (onPause) right at the top of the list.
I Added a Macro instead of searching for more stuff... there doesn't appear to be a direct way of doing this, so this way works.
精彩评论