Code completion is an invaluable tool that shows you contextual options for completing the piece of code that you are trying to write. For example, in the editor tab for the MainActivity.js file, locate the line that reads.
setContentView(R.layout.activity_main);
Place your cursor after this line and press the Enter Key . On the new line , type the letter R , and then type a period, as shown here:
R.
Android Studio Code Completion should display a list of values that you could use to try to complete the code statement. Figure shows what this list might look like . this is important if you are not entirely sure of the spelling of a method call or how to identify the different method signatures.
NOTE if the code completion window does not open , press Ctrl + Space to force it to open. This is the same key combination used in some other IDEs for their versions of the code completion.
You can also use code completion to insert code stubs into your classes . If you are inheriting from a class that has methods you must override , code completion notifies you that there are methods that need to be overridden. With a click , it inserts the stubs of those methods into your application.
Finally , the ability to import packages is one of the Android Studio features and its code completion implementation that you will use most often while navigating the examples in this blog.
For example , if you were to attempt to create a variable of a type that belongs to a package that you have not imported , Android Studio recognizes this and underlines the type with a red squiggle . Set the cursor to that line and press Alt+Enter to automatically import the package into a using statement at the top of your code file.
setContentView(R.layout.activity_main);
Place your cursor after this line and press the Enter Key . On the new line , type the letter R , and then type a period, as shown here:
R.
Android Studio Code Completion should display a list of values that you could use to try to complete the code statement. Figure shows what this list might look like . this is important if you are not entirely sure of the spelling of a method call or how to identify the different method signatures.
NOTE if the code completion window does not open , press Ctrl + Space to force it to open. This is the same key combination used in some other IDEs for their versions of the code completion.
You can also use code completion to insert code stubs into your classes . If you are inheriting from a class that has methods you must override , code completion notifies you that there are methods that need to be overridden. With a click , it inserts the stubs of those methods into your application.
Finally , the ability to import packages is one of the Android Studio features and its code completion implementation that you will use most often while navigating the examples in this blog.
For example , if you were to attempt to create a variable of a type that belongs to a package that you have not imported , Android Studio recognizes this and underlines the type with a red squiggle . Set the cursor to that line and press Alt+Enter to automatically import the package into a using statement at the top of your code file.
Comments
Post a Comment