Thursday, April 10, 2014

How to Code Android Apps



1. Open a Web browser and download the Eclipse software. Eclipse downloads in a zip file format. Extract the zip file to the 'C:\eclipse' directory. The 'Eclipse.exe' file opens the software. Eclipse does not have an installer, so you do not need to perform any installation other than extracting the zip file to a folder.

2. Install the Android SDK. The Android SDK provides the drivers for each Android version. Open a new browser tab and navigate to the Android download site. After the ZIP file downloads, extract the file content to a folder and double-click the 'install.exe' file. It takes several minutes to install all versions of the SDK, but after the installation completes, Eclipse has the ability to create Android apps.

3. Create the Android virtual device in Eclipse. The virtual device allows you to test the software using a window that looks like a user's cell phone or Android tablet. To create a virtual device, click the 'Window' menu item in Eclipse and select 'Android SDK and AVD Manager.' Type a name for the virtual device and choose an Android version for which you want to code. Click 'OK' to create the device.

4. Click the 'File' menu item and select 'New,' then 'Project.' Click the 'Android Project' type in the first window, then choose 'Next.' Type a name for your project and choose an Android version from the list. Click 'Finish' to create the project template. Eclipse opens the project template in a work space window where you type all your Java code and layout XML.

5. Create your first application. Double-click the main '.java' file in the left panel. Eclipse automatically creates a Java file to get started with a new project. Type the following code to display a simple message on the phone or tablet:super.onCreate(savedInstanceState);TextView mycustomview = new TextView(this);mycustomview.setText('My first app');setContentView(mycustomview);

6. Click the 'Save' button to save the changes. Select the 'Run' button at the top of the Eclipse menu to run the new code in the virtual device you created earlier. The code runs and displays a message in the Android SDK emulator software.

No comments:

Post a Comment