In this page, I am going to show four useful tips that are helpful to you while you are developing your Android app in Android Studio.
1. Rename package
You have two or three similar projects. The first one was completely done and the second one will be created quickly by modifying some parts of the first project. Each project cannot have the same name. So, you have to rename it.
To rename a package in Android Studio, in your project directory structure, you expand apps directory. Next, expand src directory. Double-click the main directory. Then double-click java. You will see the package name of your project. Right-click it and choose Refactor. You see a window dialog that allows you rename the package. Click Rename package button.
Then enter the new name of the package in the renaming box. Click Refactor button to finish the task.
By renaming the package, you need to update applicationId attribute in the build.gradle file to match the new package name.
2. Import classes
In Eclipse to import a class from library into your project, you hover the mouse over the class name. Then you choose to import the class from the dialog that appears. In Android studio, you need to click the class that you want to import. Then press Alt+Enter.
3. Display java doc
In Android Studio, to display documentation of a class or method, you click on the name of the class or method. Then press Ctrl+q.
Alternatively, you can enable the editor to display java doc when you move the mouse over the class or method. You select File from the menu. Then select Settings. Under IDE Settings, you select Editor. In the Editor window, you select the Show quick doc on mouse move checkbox.
4. Show line numbers
Having line number displayed in code editor is helpful while you are coding and debugging your application. In Android Studio, from the menu, you select File. Then choose Settings. Under IDE Settings, you double-click Editor. After that, you select Appearance. Finally you select the Show line numbers checkbox and click OK.
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: