Skip to content

Commit

Permalink
Merge pull request #2240 from ShampooQ/master
Browse files Browse the repository at this point in the history
#4 #900 实验四节假日
  • Loading branch information
zengsn authored May 24, 2018
2 parents fd37e46 + 9be4b72 commit 1450630
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 11 deletions.
42 changes: 42 additions & 0 deletions Soft1614080902113/APP/java/Main2Activity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.example.hao.soft1614080902145;

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

public class Main2Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent(Main2Activity.this,Message_Activity.class);
startActivity(intent);
}
});

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

Button button3=(Button)findViewById(R.id.button3);
button3.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent(Main2Activity.this,Personal_Activity.class);
startActivity(intent);
}
});
}
}
24 changes: 24 additions & 0 deletions Soft1614080902113/APP/java/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.hao.soft1614080902145;

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

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button1=(Button)findViewById(R.id.buttonl);
button1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
Intent intent=new Intent(MainActivity.this,Main2Activity.class);
startActivity(intent);
}
});
}
}
Binary file added Soft1614080902113/APP/pc4.1 (1).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 Soft1614080902113/APP/pc4.1 (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions Soft1614080902113/APP/report4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 第四次实验

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

## 2. 实验要求
1. 使用其中一种布局方式,设计所选题目的界面:LinearLayout、RelativeLayout、TableLayout、AbsoluteLayout、ListView、GridView;
2. 通过控件ID获取界面对象,执行相关操作:<br>`android:id="@+id/my_button"`
3. 实现界面控件的事件处理,例如点击按钮:<br>
`@Override`<br>
`public void onClick(View v) {`<br>
`......`<br>

## 3. 实验步骤
1. 新建一个`CityInfoActivity`,并改写其内容,实现按钮监听接口;
2.`res/layout`下编写相应的`activity_cityinfo.xml`文件,这里我将`btn_back点击按钮`放在`RelativeLayout`布局里,实现界面控件的事件处理。
`activity_cityinfo.xml`的整个布局是用`LinearLayout`布局实现的,所以在这个实验里实现了布局的嵌套。
3. 另外还自定义了滚动条(默认是ListView自带的),在`ListView`标签添加<br>
`android:scrollbarSize="10dp"` <br>
`android:scrollbarThumbVertical="@drawable/minibar"` <br>
`android:scrollbarDefaultDelayBeforeFade="1200"`
4. 检查好预览效果,整理好界面的布局以及控件的位置。最好用虚拟机运行即可。`
5. 使用Git将代码提交到自己的库中:
>$ git pull <br>
>$ git add 学号目录/* <br>
>$ git commit "#12345678 "<br>
>$ git push <br>
6. 编辑实验报告,然后将项目目录一并pull给老师;



## 4. 实验结果
我的截图1:<br><br>
![image](https://github.com/ShampooQ/android-labs-2018/blob/master/Soft1614080902113/APP/pc4.1%20(1).png)

我的截图2:<br><br>
![image](https://github.com/ShampooQ/android-labs-2018/blob/master/Soft1614080902113/APP/pc4.1%20(2).png)


## 5. 实验体会
1. 了解了集成环境的便捷性
2. 尝试了LinearLayout和ListView两种布局方式,感觉良好。
3. 希望在接下来的时间把app的UI和功能完善好。
4. 学会了如何快速布局。
27 changes: 16 additions & 11 deletions Soft1614080902113/APP/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.hzu.myapplication.MainActivity">
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/timg" />

<Button
android:id="@+id/buttonl"
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>
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:layout_marginBottom="68dp"
android:text="查询"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="151dp" />
</RelativeLayout>
79 changes: 79 additions & 0 deletions Soft1614080902113/APP/res/layout/activity_main2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".Main2Activity">

<Button
android:id="@+id/button"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="春节"
tools:layout_editor_absoluteX="102dp"
tools:layout_editor_absoluteY="75dp" />

<TextView
android:id="@+id/textView"
android:layout_width="72dp"
android:layout_height="29dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="主菜单"
tools:layout_editor_absoluteX="156dp"
tools:layout_editor_absoluteY="16dp" />

<Button
android:id="@+id/button2"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/button"
android:text="植树节"
tools:layout_editor_absoluteX="102dp"
tools:layout_editor_absoluteY="170dp" />

<Button
android:id="@+id/button3"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/button2"
android:text="圣诞节"
tools:layout_editor_absoluteX="102dp"
tools:layout_editor_absoluteY="264dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="@drawable/beijing" />

<Button
android:id="@+id/button7"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/button3"
android:text="愚人节" />

<Button
android:id="@+id/button8"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/button7"
android:text="劳动节" />

<Button
android:id="@+id/button9"
android:layout_width="400dp"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:text="国庆节" />

</RelativeLayout>

0 comments on commit 1450630

Please sign in to comment.