forked from hzuapps/android-labs-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 一、实验目标 | ||
|
||
1. 搭建 Android(Android Studio)开发环境; | ||
2. 熟悉并掌握Git与GitHub.com提交实验代码的方法。 | ||
|
||
# 二、实验内容 | ||
|
||
1. 搭建Android Studio环境,配置SDK; | ||
2. 创建一个名为Net学号Activity的java类; | ||
3. 安装git,熟悉git bash的命令; | ||
4. 上交实验相关文件 | ||
|
||
# 三、实验步骤 | ||
|
||
1. Fork hzuapps/android-labs-2020到自己的账号下 | ||
2. 在自己的电脑建立本地仓库克隆android-labs-2020的内容 | ||
3. 搭建Android Studio环境,配置SDK | ||
4. 创建Net1814080903139Activity的java类 | ||
5. 利用git bash来提交相关的文件到hzuapps/android-labs-2020 | ||
|
||
# 四、实验结果 | ||
|
||
![实验一](D:\Desktop\Markdown\移动应用开发\lab1result.PNG) | ||
|
||
|
||
|
||
# 五、实验心得体会 | ||
|
||
第一次使用git bash 提交文件,对于需要使用到的相关命令比较陌生。例如提交代码可以使用通配符,不用把具体的完整路径都打出来。 再有,在配置全局邮箱地址及用户名,刚开始总是把邮箱当成用户名输入,结果出错,最后再重新看了一遍提示才改正过来。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# 一、实验目标 | ||
|
||
1. 创建2-3个与自己选题有关的Activity | ||
2. 利用Intent实现Activity间的跳转 | ||
|
||
# 二、实验内容 | ||
|
||
1. 根据功能创建相应的Activity; | ||
2. 编写Activity对应的布局文件; | ||
3. 实现各个Activity之间的跳转; | ||
|
||
# 三、实验步骤 | ||
|
||
1. 创建Activity和xml文件 | ||
2. 在AndroidManifest.xml添加虚拟机打开时所需要的权限 | ||
|
||
``` | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androids"> | ||
<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=".TimeActivity" | ||
android:parentActivityName=".Net1814080903139Activity"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value=".Net1814080903139Activity"></meta-data> | ||
</activity> | ||
<activity | ||
android:name=".AlarmActivity" | ||
android:parentActivityName=".Net1814080903139Activity"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value=".Net1814080903139Activity"></meta-data> | ||
</activity> | ||
<activity | ||
android:name=".TimerActivity" | ||
android:parentActivityName=".Net1814080903139Activity"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value=".Net1814080903139Activity"></meta-data> | ||
</activity> | ||
<activity | ||
android:name=".StopWatchActivity" | ||
android:parentActivityName=".Net1814080903139Activity"> | ||
<meta-data | ||
android:name="android.support.PARENT_ACTIVITY" | ||
android:value=".Net1814080903139Activity" /> | ||
</activity> | ||
</application> | ||
</manifest> | ||
``` | ||
|
||
1. 在Net1814080903139Activity中添加跳转按钮的代码 | ||
|
||
``` | ||
public class Net1814080903139Activity extends AppCompatActivity { | ||
private Net1814080903139Activity myThis; | ||
protected void onCreate(Bundle savedInstanceState){ | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1814080903139); | ||
myThis=this; | ||
Button alarmButton = findViewById(R.id.AlarmButton), | ||
timerButton=findViewById(R.id.TimerButton), | ||
stopwatchButton=findViewById(R.id.StopWatchButton); | ||
alarmButton.setOnClickListener(new View.OnClickListener(){ | ||
public void onClick(View view){ | ||
Intent alarmIntent=new Intent(myThis,AlarmActivity.class); | ||
startActivity(alarmIntent); | ||
} | ||
}); | ||
timerButton.setOnClickListener(new View.OnClickListener(){ | ||
public void onClick(View view){ | ||
Intent timerIntent=new Intent(myThis,TimerActivity.class); | ||
startActivity(timerIntent); | ||
} | ||
}); | ||
stopwatchButton.setOnClickListener(new View.OnClickListener(){ | ||
public void onClick(View view){ | ||
Intent stopwatchIntent=new Intent(myThis,StopWatchActivity.class); | ||
startActivity(stopwatchIntent); | ||
} | ||
}); | ||
} | ||
} | ||
``` | ||
|
||
# 四、实验结果 | ||
|
||
![lab2](D:\Desktop\Markdown\移动应用开发\lab2result.PNG) | ||
|
||
# 五、实验心得 | ||
|
||
学习了如何利用按钮来进行页面跳转的操作,根据所选题目创建了与项目功能相关的4个Activity,学习到了如何通过Intent实现Activity间的跳转。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# 一、实验目标 | ||
|
||
1. 了解Android应用中各种资源的概念与使用方法; | ||
2. 掌握在Android应用中使用图片等资源的方法。 | ||
|
||
# 二、实验内容 | ||
|
||
1. 在界面上显示至少一张图片(按照自己的题目添加); | ||
2. 提交res/drawable及图片使用的代码; | ||
3. 提交res/values, res/layout等其他代码; | ||
|
||
# 三、实验步骤 | ||
|
||
1. 把图片.png文件放入res\drawable目录下 | ||
2. 在layout\activity_main.xml中添加使用图片资源的代码 | ||
|
||
``` | ||
<ImageView | ||
android:layout_width="match_content" | ||
android:layout_height="wrap_content" | ||
android:src="@drawable/clock" | ||
tools:ignore="MissingConstraints" | ||
tools:layout_editor_absoluteX="116dp" | ||
tools:layout_editor_absoluteY="222dp" /> | ||
``` | ||
|
||
|
||
|
||
# 四、实验结果 | ||
|
||
![Lab3](D:\Desktop\Markdown\移动应用开发\lab3.PNG) | ||
|
||
# 五、实验心得 | ||
|
||
这次实验学习了如何使用图片资源, 实验过程中,运行在虚拟机上后,图片的位置不是自己预设的结果,尝试了改变图片大小、调整水平或垂直距离都没办法改变,最后改变布局方式得以解决。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
# 一、实验目标 | ||
|
||
1. 根据选题要求设计界面布局及控件使用; | ||
2. 布局xml及界面控制操作代码提交并截图; | ||
3. 将应用运行结果截图。 | ||
|
||
# 二、实验内容 | ||
|
||
1. 用一种布局方式设计界面; | ||
2. 通过控件ID获取界面对象,执行相关操作: | ||
|
||
``` | ||
// XML | ||
android:id="@+id/my_button" | ||
// Java | ||
findViewById(R.id.my_button); | ||
``` | ||
|
||
1. 实现界面控件的事件处理; | ||
2. 操作之后,切换到第二个界面。 | ||
|
||
# 三、实验步骤 | ||
|
||
1. 根据自己项目设置了Fragment界面布局 | ||
|
||
以下是部分代码: | ||
|
||
```java | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<!--1. 存放四个Fragment--> | ||
<FrameLayout | ||
android:id="@+id/content" | ||
android:layout_width="match_parent" | ||
android:layout_height="0dp" | ||
android:layout_weight="1"></FrameLayout> | ||
<!--2. 底部的四个选项菜单--> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="60dp" | ||
android:background="#F3EDED" | ||
android:baselineAligned="false"> | ||
<!--四个部分都一样:ImageView + TextView--> | ||
<RelativeLayout | ||
android:id="@+id/first_layout" | ||
android:layout_width="0dp" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1"> | ||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerVertical="true" | ||
android:orientation="vertical"> | ||
<ImageView | ||
android:id="@+id/first_image" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:src="@drawable/clock" | ||
android:contentDescription="@string/todo" /> | ||
<TextView | ||
android:id="@+id/first_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:layout_marginTop="5dp" | ||
android:text="@string/time" | ||
android:textColor="#7597B3" /> | ||
</LinearLayout> | ||
</RelativeLayout> | ||
</LinearLayout> | ||
</LinearLayout> | ||
|
||
``` | ||
|
||
|
||
|
||
2. 根据选题所需的功能设置对应4个的界面文件,以time.xml为例。 | ||
|
||
```java | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:background="@color/lightyellow" | ||
android:orientation="vertical"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/first" | ||
android:textSize="22sp"/> | ||
</LinearLayout> | ||
``` | ||
|
||
3.修改MainActivity.java以及4个功能类,实现Activity跳转。 | ||
|
||
4.优化背景颜色以及按键图标。 | ||
|
||
```java | ||
android:background="@color/lightyellow" | ||
|
||
android:src="@drawable/clock" | ||
``` | ||
|
||
# 四、实验结果 | ||
|
||
![1](D:\Desktop\Markdown\移动应用开发\lab4_1.PNG)<img src="D:\Desktop\Markdown\移动应用开发\lab4_2.PNG" alt="2" /> | ||
|
||
![3](D:\Desktop\Markdown\移动应用开发\lab4_3.PNG)![4](D:\Desktop\Markdown\移动应用开发\lab4_4.PNG) | ||
|
||
|
||
|
||
![5](D:\Desktop\Markdown\移动应用开发\lab3.PNG) | ||
|
||
# 五、实验心得体会 | ||
|
||
这次实验我刚开始使用的控件是Tabhost ,后来因发现控件已经被弃用,操作起来有些困难,所以我改用了Fragment界面布局。 | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.