Learning about Android has been intermittent for some time. Because I've been developing iOS before, see my iOS Development Series blog, my objective-c series article , and Spy on Swift's blog description and its swift version update , " design Pattern Series ", " refactoring series article ", There are many similarities between Android and iOS when it comes to Android, and the use of controls is pretty much the same, because I've been in touch with Java EE before, so it's a lot easier to get Android.
or simple, this blog first briefly explain how to build the Android environment under the MAC (Windows Build environment of the tutorial online catch a lot of). This blog is based on Android studio, after all, is the IDE specifically developed Android. Simulator is used by the third party: Genymotion, or relatively easy to use, very smooth (but to the iOS simulator or worse). When the environment is set up, an empty activity project (similar to the single View application of iOS) is created and then the catalog of the project is introduced. Okay, cut the crap and start today's theme.
I. Environmental construction
1. Installation of JDK
This blog use when JDK8, readers can self-Baidu, and then install the JDK. Which is the Java development environment. The Java icon appears in System Preferences after installation. Click on the Java icon to start as shown below. Then you can manage your JDK here, and you can do things like check for updates. Of course, I have updated to the latest version. For specific information, please see.
2. Installation of the tools required for Android development
The following four are the tools that are currently available for Android development and are essential tools. Android Studio: Android-developed IDE, Genymotion and genymotion shell:android Simulator and Shell tool, VirtualBox: Simulator required for Android emulator genymotion to run, VirtualBox is powerful, similar to VM virtual Tools on Windows. These tools in this do not do too much to repeat, please Google or Baidu installation.
3.Genymotion Simple to use
Open the genymotion as shown. Start: You can start the emulator you have installed before. Add: Download the new Android simulator. Settings: Set up some configuration items, such as accounts, networks, and so on. The list below is your virtual device, and you can set up and delete the virtual machine. Select the device and click Start to run the virtual device.
Ii. Creation of the project
1. Open Android Studio
Open the Android studio in Launchpad and open the interface as shown below, the Welcome to Android studio interface below is the same as Welcome Xcode in Xcode. On the left you have created too many projects, you can select Open here. On the right is some other action, where click Start a new Android Studio project to create a project. (In the Xcode Welcome screen, creat new Xcode project is creating a new iOS project.)
2. Configure a new project
(1) After the previous step, the following dialog box appears, which allows you to configure some basic information about the project. such as application name (name of the app) HelloWorld, company domain (corporate domain name): such as ludashi.cnblogs.cn. The package name is automatically generated according to application name and company domain, which is generated in the development with Android studio. But if you look at him, you can edit it by tapping edit.
(2) You will then be asked to choose the backward compatible Android SDK, where we choose API 15 and later on how to manage the Android SDK via Android Studio.
(3) Next to select an activity type, in which we select the blank activity. Activities in Android development is called activity, in fact, you see the mobile interface, the control is placed on the activity. Android's activity is similar to the Uiviewcontroller in iOS development, and is all about managing the interface. This blank activity is equivalent to the single View application in iOS development and automatically generates a blank activity after the project is created. You can add multiple activity and then switch between multiple activity.
(4) After selecting the blank activity will accompany the activity of some information, you can configure the activity name (activity name), the name of the control layout of the activity (layout name), As well as the title of the activity and the name of the menu resource (menu Resource name), as to the details of the above configuration items, the blog will give you a detailed introduction.
(5) is the interface that appears after clicking Finish, which is the interface that appears after the project is created. First a dialog box appears, which prompts you to use the method of Android studio, which you can browse.
Third, Android studio simple to use
1. Switch the project catalog display mode: Click the Android drop-down menu on the project file, the drop-down menu as shown below, the first time after creating the project is Android, we can switch to project mode to view all the files in the project.
2. The file directory under Project mode is as follows, select a few more important to introduce. The project resource file directory in Android Studio is somewhat different from eclipse, but there are some files, and the file name is the same. First of all, the src file, in SRC has Java source code, the layout of the XML is responsible for the. Where the Java folder in the Java source code, res files are stored in a number of resources files, tablets, layout of XML, string resources, style resources, and so on, these will be used in development, and later used in the place will be detailed introduction. Androidmanifest.xml is a resource file for the entire Android project. In concrete things, which are used later to the place in the introduction.
3. Run your Hello Word project
(1) First open the Genymotion simulator (with the real machine can also use the real machine): Open the Genymotion Manager in Launchpad, select the previously installed Android emulator, click Start to run, wait for the project to load.
(2). Compile and run your project can run your project via the shortcut key (Control +r) or through the menu->run->run app. When you click Run, it will let you select the currently available test device, select the emulator that opens above, and the project we created will run on the selected test device.
Four. Manage your Android SDK
Android development is inseparable from the Android SDK, because there are many versions of Android, different versions of the Android SDK needs to be downloaded by the developer to use. This is different from iOS development, the iOS development tool Xcode integrates the latest SDK for iOS development, does not require users to download, if you want to use the previous, you have to download. With Android Studio, you can manage your adroid SDK. The steps are as follows:
(1) tools->android-> SDK Manager in the menu in Android Studio
(2) Open Android SDK Manager as shown here, where you can download, update, and delete different versions of the Android SDK.
Today's blog on the first, do a start, will continue to update the Android development blog, will be detailed introduction of Android development, when necessary, will give iOS development analogy.
Android development based on Androidstudio Environment building and engineering creation