How easily have their own APP? You need to know to build routines

The new Core Cloud This tutorial teaches you to use Android Studio to build the basis of a simple Android application (APP) knowledge, now with the Android phone, tablet and other equipment is becoming increasingly popular, demand for Android developers can only increase It will not be reduced. Although this tutorial is a simple-to-use development environment is very suitable for learning, but the best use of this tutorial when there is a certain understanding of the Java language editing, this will not involve too much code that allows you to easily create the first an Android application.

 

Android

1. Install Android Studio

Although the software is in English, but in accordance with a very simple, all the way Next to go to!

 

Android Studio

2. Create a new task

Open the Android Studio.

In the next "quick start" menu, select "Start a new Android Studio project."

In the open "Create New Project" window, name the project "HelloWorld".

If you choose, you need to set your company name according to *.

Note the location of the project file, and make changes as needed.

Click Next. "

Ensure that the "phone and tablet computer" check box is selected only.

If you plan to test the application on your phone, make sure that the minimum SDK below the phone's operating system level.

Click Next. "

Select "Blank activity."

Click Next. "

Retain all "Event Name" field.

Click "Finish."

 

Create a new task 1

3. The first step in creating "hellow world" welcome message


Create a new task 2

导航到activity_main.xml选项卡(如果尚未打开)。

确保在activity_main.xml显示屏上打开“设计”选项卡。

单击并拖动“你好,世界!” 从手机显示屏的左上角到屏幕中心。

在窗口左侧的项目文件系统中,打开values文件夹。

values文件夹中,双击strings.xml文件。

在此文件中,找到“ Hello world!”行。

“你好世界!” 消息中,添加“欢迎使用我的应用程序!”

导航回到activity_main.xml选项卡。

确保居中的文字现在显示为“ Hello world!欢迎使用我的应用!”

4.将按钮添加到主程序界面

导航到activity_main.xml显示的“设计”选项卡。

在电话显示屏左侧的“调色板”菜单中,找到“按钮”(在“小部件”标题下)。

单击并拖动“按钮”以将其置于欢迎消息的中央。

确保您的按钮仍处于选中状态。

“属性”菜单(在窗口的右侧)中,向下滚动以查找“文本”的字段。

将文本从“新建按钮”更改为“下一页”。

添加到主程序界面

5.创建次级活动界面

在项目的文件系统树的顶部,右键单击“应用程序”。

浏览至“新建”>“活动”>“空白活动”。

将此活动的名称更改为“ SecondActivity”。

点击“完成”。

确保您处于activity_second.xml的“设计”视图中。

像在“主要活动”中一样,将电话显示屏左上方的文本框向下拖动到中间。

在文本框仍处于选中状态的情况下,在右侧的“属性”菜单中找到“ id”字段,并将其设置为“ text2”。

再次打开strings.xml。

“ Hello world!欢迎使用我的应用!”下添加新行。显示为“欢迎使用第二页!”。

导航回到activity_second.xml。

再次选择文本框。

“属性”窗格中,将“文本”字段设置为“ @ string / second_page”。

确保文本框现在显示为“欢迎使用第二页!” 并且位于电话显示屏的屏幕中央。

 

创建次级活动界面

6.选项卡

编辑按钮的“>选择工作环境顶部的MainActivity.java选项卡。

6.1onCreate方法的末尾添加以下代码行:

按钮button =(按钮)findViewById(R.id.button);

button.setOnClickListener(new View.onClickListener(){

@Override

public void>goToSecondActivity();

}

});

6.2MainActivity类的底部添加以下方法:

私人无效goToSecondActivity(){

Intent intent = new Intent(this,SecondActivity.class);

startActivity(intent);

}

单击MainActivity.java第三行中import旁边的+,以展开import语句。

6.3如果以下内容不在导入语句的末尾,请添加这些内容:

导入android.content.Intent;

导入android.view.View;

导入android.widget.TextView;

7.测试与完成

点击Android Studio窗口顶部工具栏中的绿色播放符号。

当出现“选择设备”对话框时(这可能需要一些时间),请选择“ Lauch emulator”选项。

单击确定。

当模拟器打开时(这可能也需要一段时间),该应用程序将在解锁虚拟电话后自动启动该应用程序。

 

测试与完成

确保所有文本正确显示,并且该按钮将您带到下一页。

恭喜!现在,您已经完成了第一个具有一些基本功能的Android应用程序

长按二维码,关注我们

新睿云,让云服务触手可及

云主机|云存储|云数据库|云网络


Published 217 original articles · won praise 15 · views 110 000 +

Guess you like

Origin blog.csdn.net/bingbob/article/details/104218281
Recommended