Android开发新手系列之HelloWorld

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

这里写图片描述
这里写图片描述
这里写图片描述

创建一个不带Activity的空程序

这里写图片描述

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

这里写图片描述

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

这里写图片描述
这里写图片描述

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

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

编写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);
    }
}

这里写图片描述

编写系统文件,将HelloWorldActivity设置为MAIN,意味着在程序启动时首先启动HelloWorldActivity显示界面

<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>

这里写图片描述

编写布局文件

<?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 APP程序,并且选择已经启动好的模拟器

这里写图片描述

HelloWorld程序运行结果

这里写图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值