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 #1449 from joshua-ben/master
Browse files Browse the repository at this point in the history
#3 #4 第3、4次实验报告
  • Loading branch information
zengsn authored Dec 25, 2020
2 parents c469bec + e6a55f1 commit 9aae46f
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
59 changes: 59 additions & 0 deletions students/net1814080903323/lab3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 实验三:Android资源使用编程
## 一、实验目标
- 了解Android应用中各种资源的概念与使用方法;
- 掌握在Android应用中使用图片等资源的方法。

## 二、实验内容
- 在界面上显示至少一张图片(按照自己的题目添加);
- 提交res/drawable及图片使用的代码;
- 提交res/values, res/layout等其他代码;
- 将应用运行结果截图,放到实验报告中;
- 点击图片(或按钮)时,打开另一个Activity。

## 三、实验步骤
- 在res/drawable目录中放入图片(bg.jpg);
- 在主界面上添加ImageView组件,通过ImageView组件实现在主界面上展示图片;
- 在主界面的xml文件上对ImageView组件进行配置;
- 设计方法实现界面的跳转,然后在按钮上应用该方法。
```java
<ImageView
android:id="@+id/imageView"
android:layout_width="194dp"
android:layout_height="355dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="10dp"
android:src="@drawable/cat1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints" />

<ImageView
android:id="@+id/imageView2"
android:layout_width="194dp"
android:layout_height="355dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="205dp"
android:src="@drawable/cat2"
app:layout_constraintStart_toEndOf="@+id/imageView"
app:layout_constraintTop_toTopOf="@+id/imageView"
tools:ignore="MissingConstraints" />

<ImageView
android:layout_width="194dp"
android:layout_height="355dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="205dp"
android:src="@drawable/cat3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/imageView2"
tools:ignore="MissingConstraints" />
```

## 四、实验结果
![图片](https://github.com/joshua-ben/android-labs-2020/blob/master/students/net1814080903323/test3.jpg)

## 五、实验心得
这次实验的主要任务是在主界面上添加图片,使用具有添加图片功能的组件ImageView来实现在主界面添加图片,并且在主界面的xml文件上对组件ImageView进行配置。
54 changes: 54 additions & 0 deletions students/net1814080903323/lab4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 实验四:Android界面设计编程

## 一、实验目标
- 根据选题要求设计界面布局及控件使用;
- 布局xml及界面控制操作代码提交并截图;
- 将应用运行结果截图。

## 二、实验内容
- 使用一种布局方式设计界面;
- 通过控件ID获取界面对象,执行相关操作;
- 实现界面控件的事件处理;
- 操作之后,切换到第二个界面。

## 三、实验步骤
- 使用LinearLayout布局设计;
- 通过控件ID获取界面对象,执行相关操作;
- 实现界面控件的事件处理。
```java
public class Net1814080903323Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1814080903323);

final Button botton1;
botton1 = findViewById(R.id.button1);
botton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
botton1.setBackgroundColor(Color.rgb(255, 0, 0));
Intent i = new Intent(Net1814080903323Activity.this, InvitationActivity.class);
startActivity(i);
}
});
final Button botton2;
botton2 = findViewById(R.id.button2);
botton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
botton2.setBackgroundColor(Color.rgb(255, 0, 0));
Intent i = new Intent(Net1814080903323Activity.this, TipsActivity.class);
startActivity(i);
}
});

}
```

## 四、实验结果
![图片](https://github.com/joshua-ben/android-labs-2020/blob/master/students/net1814080903323/test4.jpg)

## 五、实验心得
这次实验将界面布局进行设计,增加一些功能。
Binary file added students/net1814080903323/test3.jpg
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/net1814080903323/test4.jpg
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 9aae46f

Please sign in to comment.