Android开发新手系列之HelloWorld

 时间:2026-02-14 10:53:52

1、启动Android Studio,新建工程; 配置工程名字以及包路径、工程存储路径;选择开发的Android程序运行的平台以及版本

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

2、创建一个不带Activity的空程序

Android开发新手系列之HelloWorld

3、点击左侧Project,显示工程目录结构

Android开发新手系列之HelloWorld

4、创建Java类,作为程序启动的主类;配置主类的名字以及其他类属性

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

5、创建一个布局文件目录以及布局文件,目录为layout,名字为helloworld_activity

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

Android开发新手系列之HelloWorld

6、编写HelloWorldActivity代码,主要重写Activity的onCreate方法,引用新建的布局文件activity_helloworld

package com.ww.n1.n1_helloworld;import android.app.Activity;import android.os.Bundle;import android.support.annotation.Nullable;public class HelloWorldActivity extends Activity{    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_helloworld);    }}

Android开发新手系列之HelloWorld

7、编写系统文件,将HelloWorldActivity设置为MAIN

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.ww.n1.n1_helloworld">    <application        android:allowBackup="true"        android:icon="@mipmap/ic_launcher"        android:label="@string/app_name"        android:roundIcon="@mipmap/ic_launcher_round"        android:supportsRtl="true"        android:theme="@style/AppTheme">        <activity android:name=".HelloWorldActivity">            <intent-filter>                <action android:name="android.intent.action.MAIN"/>                <category android:name="android.intent.category.LAUNCHER"/>            </intent-filter>        </activity>    </application></manifest>

Android开发新手系列之HelloWorld

8、编写布局文件

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical" android:layout_width="match_parent"    android:layout_height="match_parent">    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="Hello World"        />

</LinearLayout>

Android开发新手系列之HelloWorld

9、运行Android APP程序,并且选择已经启动好的模拟器

Android开发新手系列之HelloWorld

  • VMware安装Ubuntu教程之创建虚拟机
  • VMware Workstation如何安装ubuntu16.04.5
  • C#如何实现DES加密算法
  • IntelliJ IDEA怎么关闭显示符号空白
  • Visual Studio添加ASP.Net文件夹各选项解析
  • 热门搜索
    手腕扭伤怎么办 月经期间可以吃感冒药吗 怎么删除word中的空白页 深奥的近义词 婴儿感冒怎么办 嘴巴干是怎么回事 我的世界矿车怎么做 男生发型名字 中括号怎么打 内扣发型图片