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
1 changed file
with
65 additions
and
19 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 |
---|---|---|
@@ -1,36 +1,82 @@ | ||
# 实验二 | ||
**# 实验二** | ||
|
||
|
||
|
||
**## 一、实验目标** | ||
|
||
**1. 创建自己的选题** | ||
|
||
**2. 编写相应的Activity(有n个功能就建立n+1个Activity)** | ||
|
||
**3.对应自己的选题的功能实现Activity中的功能** | ||
|
||
## 一、实验目标 | ||
1. 创建2-3个与自己选题有关的Activity | ||
2. 利用Intent实现Activity间的跳转 | ||
|
||
## 二、实验内容 | ||
1. 根据功能创建相应的Activity; | ||
2. 编写Activity对应的布局文件; | ||
3. 实现各个Activity之间的跳转; | ||
|
||
## 三、实验步骤 | ||
1. 创建 MainActivity(主界面)、GameSceneActivity(游戏界面)、FailGameSceneActivity(游戏失败界面); | ||
2. 将创建的 Activity 注册到 AndroidManifest.xml 中; | ||
3. 在布局文件中创建 Button 组件; | ||
4. 为 Button 添加点击事件处理; | ||
5. 通过 MainActivity(Intent) 实现界面跳转; | ||
|
||
**## 二、实验内容** | ||
|
||
**1. 在Issues中创建自己的选题:https://github.com/hzuapps/android-labs-2020/issues ;** | ||
|
||
**2.根据自选题目,编写多个Activity,在主窗口类带上学号前缀,放到自己的Java包下;** | ||
|
||
**3. 将标题设置为自己的学号+对应的功能或题目;** | ||
|
||
**4. 根据自己选择的题目实现Activity中导航、调用等功能(选做)。** | ||
|
||
|
||
## 四、实验结果 | ||
![实验结果](https://github.com/1nnocent1/android-labs-2020/blob/master/students/sec1814080911125/lab2.png) | ||
|
||
**## 三、实验步骤** | ||
|
||
**1. 创建 Sec1814080911125Activity.java(主界面)、GameSceneActivity.java(游戏界面)、FailGameSceneActivity.java(游戏失败界面);** | ||
|
||
**2. 将创建的 Activity 注册到 AndroidManifest.xml 中;** | ||
|
||
**3. 在布局文件中创建 Button 组件;** | ||
|
||
**4. 为 Button 添加点击事件处理;** | ||
|
||
**5. 通过 MainActivity(Intent) 实现界面跳转** | ||
|
||
|
||
## 五、实验心得 | ||
第二次实验是根据自己所选的题目创建几个功能的Activity,然后在主Activity中使用Intent实现各个Activity的跳转。 | ||
|
||
**##四、 实验代码** | ||
|
||
1.Sec1814080911125Activity.java | ||
|
||
''' | ||
|
||
| public class MainActivity extends AppCompatActivity {<br/><br/> @Override<br/> protected void onCreate(Bundle savedInstanceState) {<br/> super.onCreate(savedInstanceState);<br/> setContentView(R.layout.activity_main);<br/><br/> final MainActivity thisActivity = this;<br/><br/> Button BtnStart=(Button)findViewById(R.id.button_start);<br/><br/> View.OnClickListener onClickListener = new View.OnClickListener() {<br/> @Override<br/> public void onClick(View v) {<br/> switch (v.getId()){<br/> case R.id.button_start:<br/> Intent intent = new Intent(MainActivity.this,GameSceneActivity.class);<br/> startActivity(intent);<br/> break;<br/> }<br/> }<br/> };<br/><br/> }<br/>} | | ||
| ------------------------------------------------------------ | | ||
| | | ||
|
||
''' | ||
|
||
2.GameSceneActivity.java | ||
|
||
''' | ||
|
||
| public class GameSceneActivity extends AppCompatActivity {<br/><br/> @Override<br/> protected void onCreate(Bundle savedInstanceState) {<br/> super.onCreate(savedInstanceState);<br/> setContentView(R.layout.activity_game_scene);<br/> }<br/>} | | ||
| ------------------------------------------------------------ | | ||
| | | ||
|
||
''' | ||
|
||
3.FailGameSceneActivity.java | ||
|
||
''' | ||
|
||
| public class FailGameSceneActivity extends AppCompatActivity {<br/><br/> @Override<br/> protected void onCreate(Bundle savedInstanceState) {<br/> super.onCreate(savedInstanceState);<br/> setContentView(R.layout.activity_fail_game_scene);<br/> }<br/>} | | ||
| ------------------------------------------------------------ | | ||
| | | ||
|
||
''' | ||
|
||
**## 五、实验结果** | ||
|
||
**![实验结果](https://github.com/1nnocent1/android-labs-2020/blob/master/students/sec1814080911125/lab2.png)** | ||
|
||
|
||
|
||
**## 六、实验心得** | ||
|
||
**第二次实验是根据自己所选的题目创建几个功能的Activity,然后在主Activity中使用Intent实现各个Activity的跳转。** | ||
|