Skip to content

Commit

Permalink
hzuapps#3 第三次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
Min4396 committed May 31, 2018
1 parent 47c9ca6 commit 764e843
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 0 deletions.
Binary file added soft1614080902434/3.0.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 soft1614080902434/3.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions soft1614080902434/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="soft1614080902434.androidlabs.hzuapps.edu.soft1614080902434">

<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=".Wechat">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Second_Activity"></activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package soft1614080902434.androidlabs.hzuapps.edu.soft1614080902434;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Second_Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second_);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package soft1614080902434.androidlabs.hzuapps.edu.soft1614080902434;

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

public class Wechat extends AppCompatActivity implements View.OnClickListener {
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wechat);
b = (Button)findViewById(R.id.but);
b.setOnClickListener(this);
}

@Override
public void onClick(View view) {
if(view==b){
Intent intent = new Intent();
intent.setClass(Wechat.this,Second_Activity.class);
startActivity(intent);
}
}

@Override
public void onPointerCaptureChanged(boolean hasCapture) {

}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions soft1614080902434/app/src/main/res/layout/activity_second_.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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=".Second_Activity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/wc"/>


</android.support.constraint.ConstraintLayout>
39 changes: 39 additions & 0 deletions soft1614080902434/app/src/main/res/layout/activity_wechat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout 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=".Wechat">

<TextView
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_x="158dp"
android:layout_y="122dp"
android:text=" Wechat "
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="23dp"
android:layout_y="408dp"
android:text="聊天"
tools:layout_editor_absoluteX="28dp"
tools:layout_editor_absoluteY="447dp" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="254dp"
android:layout_y="414dp"
android:text="表情包"
tools:layout_editor_absoluteX="262dp"
tools:layout_editor_absoluteY="447dp" />

</AbsoluteLayout>
3 changes: 3 additions & 0 deletions soft1614080902434/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">soft1614080902434</string>
</resources>
45 changes: 45 additions & 0 deletions soft1614080902434/report3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 第三次实验
## 1.实验目的
掌握在Android应用中使用图片等资源的方法
## 2.实验步骤

1、打开实验2时的工程项目

2、在edu\hzuapps\androidlabs\soft1614080902434下新建Activity,命名为Second_Activity

3、将图片wc.png粘贴至res/drawable目录下

4、在second_activity.xml中添加控件ImageView,其代码为

<ImageView

android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/wc"/>

5、在soft_1614080902434_activity.xml中添加Button控件
6、在soft1614080902419Activity类中添加Button


b,并监听,其代码如下:

@Override

public void onClick(View view) {

if(view==b){
Intent intent = new Intent();
intent.setClass(Wechat.this,Second_Activity.class);
startActivity(intent);
}
}:

8、编译运行

9、打开git bash,将文件夹push上github,向老师提交pull request.

## 3.实验结果:


## 4.实验体会:
学会了怎么新建Activity、如何添加图片、怎么切换Activity。,刚开始做的时候,因为我的电脑运行不了虚拟机,因为BIOS设置不了,所以我只能用实体机运行,而我的实体机型号是范围是1980*1080,而Android studio没有这个范围,所以就选了另一个范围,这就导致了布局有点尴尬。这次实验,算是初步了解怎么安装按钮和监听了。

0 comments on commit 764e843

Please sign in to comment.