Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3 第三次实验 #2377

Merged
merged 2 commits into from
May 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added soft1614080902242/Cache_-5bb0443569f733bb..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 soft1614080902242/Cache_46564950988ba5fc..jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions soft1614080902242/report3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 第三次实验

## 1.实验目标

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

## 2.实验要求

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

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

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

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

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

## 3.实验步骤

(1)阅读实验要求:https://github.com/hzuapps/android-labs-2018/labels/Lab

(2)在电脑上Android Studio编写代码// 代码要可以运行!

创建第二个activity

在界面上添加一张图片和一个按钮

将第二个activity链接到按钮上

(3)使用Git将代码提交到自己的库中:https://github.com/tangweibin/android-labs-2018

$ git pull

$ git add soft1614080902242/*

$ git commit "#3 第三次实验 "

$ git push

(4)在自己的GitHub库上创建和发送Pull Request(注意查看Changed files)// 是否只修改了自己的文件?

(5)在GitHub中使用Markdown文件编写实验报告(report3.md)// 保存在自己的文件夹下

## 4.实验结果

![](https://github.com/tangweibin/android-labs-2018/blob/master/soft1614080902242/Cache_-5bb0443569f733bb..jpg)

![](https://github.com/tangweibin/android-labs-2018/blob/master/soft1614080902242/Cache_46564950988ba5fc..jpg)

## 5.实验体会

卡了好久,终于补上了,后面的不知道做不做得
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package edu.hzuapps.androidlabs.soft1613090502218.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
package com.example.soft1614080902242;
package edu.hzuapps.androidlabs.soft1613090502218.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

private Button tv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tv=(Button)findViewById(R.id.test1);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
}
});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:layout_height="500sp"
android:gravity="center_vertical"
android:orientation="vertical"
tools:context="edu.hzuapps.androidlabs.soft1613090502218.myapplication.MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_gravity="top"
android:layout_height="250dp"
android:layout_width="match_parent">

</android.support.constraint.ConstraintLayout>
<ImageView
android:id="@+id/imageview"
android:layout_width="410sp"
android:layout_height="match_parent"
android:layout_gravity="top"
android:src="@drawable/bg" />
</LinearLayout>

<LinearLayout
android:layout_width="410dp"
android:layout_height="250sp"
android:layout_gravity="bottom"
android:weightSum="1">

<Button
android:text="@string/test1"
android:id="@+id/test1"
android:layout_width="match_parent"
android:layout_height="50sp"
android:layout_gravity="bottom"/>
</LinearLayout>

</LinearLayout>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">soft1614080902242三国小站</string>
<string name="app_name">soft1614080902242</string>
<string name="test1">test1</string>
</resources>