Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1536 from JeesionChone/master
Browse files Browse the repository at this point in the history
#3 #53 实验报告三
  • Loading branch information
zengsn authored Jan 2, 2021
2 parents ca8704e + aa173a3 commit e3af296
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 0 deletions.
132 changes: 132 additions & 0 deletions students/net1814080903310/lab2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# 实验二

## 一、实验目标

1.在Issues中创建自己的选题:https://github.com/hzuapps/android-labs-2020/issues

2.根据自选题目,编写一个或多个Activity(主窗口类带上学号前缀,放到自己的Java包下);

3.将标题设置为自己的学号+对应的功能或题目;

4.根据自己选择的题目实现Activity中导航、调用等功能(选做)。

## 二、实验内容

1.创建自己的安卓项目选题;

2.根据自选题在Android Studio中创建一个或多个Activity;

3.实现一个Activity与另一个Activity之间的跳转(显式或隐式)

## 三、实验步骤

1. 创建 2-3 个 Activity

2. Net1814080903310Activity.java (首页、LAUNCHER、主活动):Net1814080903310Activity.java

3.功能1Activity.java:Information1814080903310Activity

4.功能2Activity.java:PlayVideo18148080903310Activity

## 四、实验结果

```
Net1814080903310Activity.java
package edu.hzuapps.androidlabs.students.net1814080903310;
import android.os.Bundle;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;
public class Net1814080903310Activity extends AppCompatActivity {
//@Override
protected void onCreat(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = findViewById(R.id.see);
final Net1814080903310Activity _this = this;
button.setOnClickListener(new View.OnClickListener() {
//@Override
public void onClick(View v) {
Intent intent = new Intent(_this, Information1814080903310Activity.class);
_this.startActivity(intent);
}
});
}
private void startActivity(Intent intent) {
}
}
```

```
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="edu.hzuapps.androidlabs">
<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=".students.net1814080903310.PlayVideo18148080903310Activity"></activity>
<activity android:name=".students.net1814080903310.Information1814080903310Activity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Information1814080903310Activity
package edu.hzuapps.androidlabs.students.net1814080903310;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class Information1814080903310Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main1814080903310);
}
}
```

```
PlayVideo18148080903310Activity
package edu.hzuapps.androidlabs.students.net1814080903310;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class PlayVideo18148080903310Activity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first18148080903310);
}
}
```

## 五、实验心得
这次实验做的是在Activity上添加按钮,来实现Activity之间的跳转。就是在app里面点击按钮来实现页面跳转。
实验结果图片:
https://github.com/JeesionChone/android-labs-2020/blob/master/students/net1814080903310/labs2.png
149 changes: 149 additions & 0 deletions students/net1814080903310/lab3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# 实验三

## 一、实验目标

1.了解Android应用中各种资源的概念与使用方法;

2.掌握在Android应用中使用图片等资源的方法。

## 二、实验内容

1.在界面上显示至少一张图片(按照自己的题目添加);

2.提交res/drawable及图片使用的代码;

3.提交res/values, res/layout等其他代码;

4.将应用运行结果截图,放到实验报告中;

5.点击图片(或按钮)时,打开另一个Activity。

## 三、实验步骤

1.将图片放到res下的drawable文件夹

2. 在splash_activity.xml插入启动页面的图片

```
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/infomationbackground" />
```

6. 打开另外一个Activity

```
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.video);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent();
intent.setClass(Net1814080903310Activity.this,PlayVideo18148080903310Activity.class);
startActivity(intent);
}
});
button1 = (Button)findViewById(R.id.info);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(Net1814080903310Activity.this,Information1814080903310Activity.class);
startActivity(intent);
}
});
```

## 四、实验结果

```
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我的" />
<Button
android:id="@+id/video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="视频" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/infomationbackground" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
```

```
Net1814080903310Activity
package edu.hzuapps.androidlabs.students.net1814080903310;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;
import androidx.appcompat.app.AppCompatActivity;
import edu.hzuapps.androidlabs.R;
public class Net1814080903310Activity extends AppCompatActivity {
Button button = null;
Button button1 =null;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.video);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent =new Intent();
intent.setClass(Net1814080903310Activity.this,PlayVideo18148080903310Activity.class);
startActivity(intent);
}
});
button1 = (Button)findViewById(R.id.info);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setClass(Net1814080903310Activity.this,Information1814080903310Activity.class);
startActivity(intent);
}
});
}
}
```

## 五、实验心得
这次实验在主页上添加了一张图片,并且点击主页的按钮进行跳转。
实验结果图片:
https://github.com/JeesionChone/android-labs-2020/blob/master/students/net1814080903310/labs3.png
Binary file added students/net1814080903310/labs2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added students/net1814080903310/labs3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e3af296

Please sign in to comment.