<span id="Label3"></p>Get started with Android app development tutorial Font: [increase decrease] type: Reproduced This article mainly introduces the Android app development tutorial, from the SDK download, development environment building, code writing, App Packaging and other steps one by one, very concise an Android App development tutorial, the need for friends can refer to the following<p><p>Work has done mobile app projects, front-end and Android or iOS programmers to complete the development of the project, the development process with the iOS program is basically no problem, and Android a variety of machine and ROM problems, This also gives me an interest in learning Android and iOS program Development. So one o'clock in the morning can't sleep to write the first Android program Helloandroid,po out to share to other also want to learn Android development friends, Such a fool of the Android development primer, there is a little development foundation should be able to read.<br><br><strong>first, the preparatory work</strong></p></p><p><p>Mainly in my own development environment, for example, Download the installation of the JDK and Android sdk, if you do not have a ready-made IDE, you can directly download the SDK full package, which contains eclipse, if there is an IDE then you can scroll to the following choose the use of an EXISTING IDE, Then install the sdk, if your SDK does not find the JDK directory at the time of installation, you can add the Java_home variable in the system environment variable, the path to your JDK directory, my IDE is IntelliJ idea, all installed later to start configuring the IDE to add SDK Support.</p></p><p><p>first, Open the Android SDK Manager to the Android 4.0 version of the installation is not installed on the hook, according to your personal situation, if you only plan to use their own mobile phone testing, it will be the same version of your system SDK packaging, download time is a bit long.</p></p><p><p><br><br>Then open the IDE to create a new project, idea is more intelligent, if you install the sdk, the new project will appear in the Android application Module, Select the right Project SDK is empty, Click the new button, find the SDK directory ok, The Drop-down list will list the various versions of the SDK that have been installed, choose the version you want, and if it is the first time, the IDE will remind you to set up the JDK and follow the prompts to find the JDK directory.</p></p><p><p><br><br>After you have completed the project name, Select USB Device, and then complete the project build, the IDE will automatically generate the files and directories needed for the basic project.</p></p><p><p></p></p><p><p></p></p><p><p><strong>second, Code Writing</strong></p></p><p><p>After getting ready to work, we can finally start writing our Hello android, before we begin to write code, we first understand a few files:</p></p><p><p>Res/layout/main.xml app main form layout file, what your app looks like here, has design and text two modes</p></p><p><p>Res/values/strings.xml can be understood as a i18n file, which is used to store the various strings that the program calls</p></p><p><p>Src/com/example/helloandroid/myactivity.java This is our main program class, and so on, the functions to be implemented are added in this file</p></p><p><p>first, Add a TextView with ID Hellotextview for your app and a button,mail.xml code with ID Hellobutton as Follows:</p></p><span style="text-decoration: underline;"><span style="text-decoration: underline;">Copy Code</span></span>The code is as Follows:<br><?xml version= "1.0" encoding= "utf-8"?><br><linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"<br>android:orientation= "vertical"<br>Android:layout_width= "fill_parent"<br>android:layout_height= "fill_parent"<br>><br><textview<br>Android:layout_width= "fill_parent"<br>android:layout_height= "180dp"<br>android:text= "@string/default_message"<br>android:id= "@+id/hellotextview" android:textcolor= "#00ff00" android:gravity= "center"/><br><button<br>Android:layout_width= "wrap_content"<br>android:layout_height= "wrap_content"<br>android:text= "@string/button_send"<br>android:id= "@+id/hellobutton" android:layout_gravity= "center"/><br></LinearLayout><p><p></p></p><p><p>The strings used by the code and controls are defined as Follows:</p></p><p><p></p></p><span style="text-decoration: underline;"><span style="text-decoration: underline;">Copy Code</span></span>The code is as Follows: <?xml version= "1.0" encoding= "utf-8"?><br><resources><br><string name= "app_name" >helloandroid by hiwanz</string><br><string name= "button_send" >say something</string><br><string name= "default_message" >click button below!</string><br><string name= "interact_message" >you just clicked on the button!</string><br></resources><br>The main program defines a button click to change the text displayed by the textview, and a toast prompt message appears with the following code:<br><span style="text-decoration: underline;"><span style="text-decoration: underline;">Copy Code</span></span>The code is as Follows:<br>Package com.example.helloandroid;<br><br>Import android.app.Activity;<br>Import android.os.Bundle;<br>Import android.view.View;<br>Import android.widget.Button;<br>Import android.widget.TextView;<br>Import android.widget.Toast;<br><br>public class MyActivity extends Activity {<br>/**<br>* Called when the activity is first Created.<br>*/<br>@Override<br>public void OnCreate (Bundle Savedinstancestate) {<br>Super.oncreate (savedinstancestate);<br>Setcontentview (r.layout.main);<br>Get Button Instance<br>Button hellobtn = (button) Findviewbyid (r.id.hellobutton);<br>Setting the Listener button click event<br>Hellobtn.setonclicklistener (new View.onclicklistener () {<br>@Override<br>public void OnClick (View V) {<br>Get TextView instances<br>TextView Hellotv = (TextView) Findviewbyid (r.id.hellotextview);<br>The popup Toast Prompt button is clicked<br>Toast.maketext (myactivity.this, "Clicked", toast.length_short). show ();<br>Read Strings.xml defined interact_message information and write to TextView<br>Hellotv.settext (r.string.interact_message);<br>}<br>});<br>}<br><br>}<br>After the code is written, the computer is connected to the phone via a USB cable, the developer option in the phone system setup opens the USB debug, and the IDE directly points to run to see the effect on the PHONE.<p><p></p></p><p><p></p></p><p><p></p></p><p><p><strong>App Packaging</strong></p></p><p><p>After the application development is finished, package the release, Select the Generate signed APK to package the app under the Ide's build menu</p></p><p><p></p></p><p><p>In the Pop-up wizard dialog box, you need to specify the signature key, at first you can click Create new to create a new key for signing, fill in some fields required by the signature and generate a key file.<br></p></p><p><p>Use the generated key to sign the app package</p></p><p><p></p></p><p><p></p></p><p><p>After compiling, we will build our helloandroid.apk app package under the designation APK path we set up just now, and then we need to install the app.</p></p>Articles you may be interested in: <ul> <ul> <li>The idea of Android imitation chat bubble effect</li> <li>Android Get application name (applicationname) example</li> <li>Android avoids app splash screen resolution (theme and Style)</li> <li>Calling local Android app code via HTML Web page</li> <li>Avoid applying unresponsive methods in Android development (application not responding, ANR)</li> <li>Android App Add chat feature</li> </ul> </ul><p><p>Get started with Android app development tutorial</p></p></span>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service