Easy Tutorial
❮ Javascript Modals Python Dynamic Var ❯

Foolproof Android APP Development Beginner's Tutorial

Category Programming Technology

This article mainly introduces a beginner's tutorial for Android APP development, explaining step by step from SDK download, development environment setup, code writing, to APP packaging. It is a very concise tutorial for beginners in Android APP development, and those who need it can refer to it.

I have worked on mobile app projects at work, where the front end and Android or iOS programmers cooperate to complete the entire project development. There were basically no issues when working with iOS programmers, but there were many problems with various Android devices and ROMs, which sparked my interest in learning Android and iOS app development. So, I couldn't sleep at one in the morning and wrote my first Android program HelloAndroid, which I am now sharing with other friends who also want to learn Android development. Such a foolproof Android development beginner's article should be understandable for those with some development foundation.

I. Preparation Work

Taking my own development environment as an example, download and install the JDK and Android SDK. If you don't have an existing IDE, you can directly download the complete SDK package, which includes Eclipse. If you have an IDE, you can scroll down and select USE AN EXISTING IDE, then install the SDK. If your SDK cannot find the JDK directory during installation, you can add the JAVA_HOME variable to the system environment variables, with the path to your JDK directory. My IDE is IntelliJ IDEA, and after everything is installed, start configuring the IDE to add SDK support.

First, open the Android SDK Manager and check all the versions above Android 4.0 that are not installed. According to your personal situation, if you only plan to test with your own phone, install the SDK package that matches your phone's system version. The download time is a bit long.

Then open the IDE to create a new project. IDEA is quite smart; if you have installed the SDK, the Android Application Module will appear in the new project. After selecting it, the Project SDK on the right is empty. Click the New button, find the SDK directory to confirm, and the drop-down list will show the installed versions of the SDK. Choose the version you need. If it's your first time setting it up, the IDE will remind you to set up the JDK first, and you can find the JDK directory according to the prompts.

After filling in the project name, go to the next step and select USB Device, then complete the project build. The IDE will automatically generate the basic files and directories required for the project.

II. Code Writing

After the preparatory work is done, we can finally start writing our hello android. Before starting to write the code, let's understand a few files:

res/layout/main.xml The main layout file of the App, where the appearance of your application is defined, with two modes: Design and Text.

res/values/strings.xml It can be understood as an i18n file, which is used to store various strings called by the program.

src/com/example/helloandroid/MyActivity.java This is our main program class, where the functions to be implemented will be added.

First, add a textview with the id hellotextView and a button with the id hellobutton to the application, and the mail.xml code is as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <TextView
            android:layout_width="fill_parent"
            android:layout_height="180dp"
            android:text="@string/default_message"
            android:id="@+id/hellotextView" android:textColor="#00ff00" android:gravity="center"/>
    <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button_send"
            android:id="@+id/hellobutton" android:layout_gravity="center"/>
</LinearLayout>

The string definitions used by the code and controls are as follows:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">helloandroid by hiwanz</string>
    <string name="button_send">Say something</string>
    <string name="default_message">Click button below!</string>
    <string name="interact_message">You just clicked on the Button!</string>
</resources>

In the main program, define the button click to change the text displayed by the textview and pop up a Toast prompt message, and the code is as follows:

``` package com.example.helloandroid;

import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import

❮ Javascript Modals Python Dynamic Var ❯