Skip to content

Commit

Permalink
Merge pull request #1719 from linwt/master
Browse files Browse the repository at this point in the history
#4 第四次实验
  • Loading branch information
zengsn authored May 9, 2018
2 parents 73204cd + a468ed0 commit 8165091
Show file tree
Hide file tree
Showing 12 changed files with 291 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,62 @@

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class startActivity extends AppCompatActivity {

private Button button;
private RadioGroup radioGroup1;
private RadioGroup radioGroup2;
private RadioButton stone1;
private RadioButton stone2;
private RadioButton scissors1;
private RadioButton scissors2;
private RadioButton cloth1;
private RadioButton cloth2;
private TextView result_textview;

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


button=(Button)findViewById(R.id.startButtonId);
radioGroup1= (RadioGroup)findViewById(R.id.radioGroup1Id);
radioGroup2= (RadioGroup)findViewById(R.id.radioGroup2Id);
stone1= (RadioButton)findViewById(R.id.stone1Id);
stone2= (RadioButton)findViewById(R.id.stone2Id);
scissors1=(RadioButton)findViewById(R.id.scissors1Id);
scissors2=(RadioButton)findViewById(R.id.scissors2Id);
cloth1=(RadioButton)findViewById(R.id.cloth1Id);
cloth2=(RadioButton)findViewById(R.id.cloth2Id);
result_textview=(TextView)findViewById(R.id.resultId);

ButtonListener listerner=new ButtonListener();
button.setOnClickListener(listerner);
}


class ButtonListener implements android.view.View.OnClickListener{

@Override
public void onClick(View v) {
if(radioGroup1.getCheckedRadioButtonId()==R.id.stone1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.stone2Id||radioGroup1.getCheckedRadioButtonId()==R.id.scissors1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.scissors2Id||radioGroup1.getCheckedRadioButtonId()==R.id.cloth1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.cloth2Id){
result_textview.setText("打成平局啦!");
}
else if(radioGroup1.getCheckedRadioButtonId()==R.id.stone1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.scissors2Id||radioGroup1.getCheckedRadioButtonId()==R.id.stone1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.cloth2Id||radioGroup1.getCheckedRadioButtonId()==R.id.scissors1Id&&radioGroup2.getCheckedRadioButtonId()==R.id.cloth2Id){
result_textview.setText("阿狸赢啦!");
}
else{
result_textview.setText("桃子赢啦!");
}
}
}

}
Binary file added soft1614080902318/#3/res/drawable/ali.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 soft1614080902318/#3/res/drawable/taozi.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
138 changes: 136 additions & 2 deletions soft1614080902318/#3/res/layout/activity_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,144 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:title="@string/title_activity_start"
app:popupTheme="@style/AppTheme.PopupOverlay" />
app:popupTheme="@style/AppTheme.PopupOverlay"
app:title="@string/title_activity_start" />

</android.support.design.widget.AppBarLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_marginTop="50dp"
android:orientation="horizontal">

<LinearLayout
android:layout_width="0dp"
android:layout_height="350dp"
android:layout_weight="1"
android:orientation="vertical">


<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:src="@drawable/ali" />

<TextView
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_marginLeft="40dp"
android:text="玩家1:阿狸"
android:textSize="20dp"/>

<RadioGroup
android:id="@+id/radioGroup1Id"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="60dp">

<RadioButton
android:id="@+id/stone1Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="石头" />

<RadioButton
android:id="@+id/scissors1Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="剪子" />

<RadioButton
android:id="@+id/cloth1Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="" />

</RadioGroup>

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="350dp"
android:layout_weight="1"
android:orientation="vertical">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:src="@drawable/taozi" />

<TextView
android:layout_width="120dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_marginLeft="40dp"
android:text="玩家2:桃子"
android:textSize="20dp"/>

<RadioGroup
android:id="@+id/radioGroup2Id"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginLeft="60dp">

<RadioButton
android:id="@+id/stone2Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="石头" />

<RadioButton
android:id="@+id/scissors2Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="剪子" />

<RadioButton
android:id="@+id/cloth2Id"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="" />

</RadioGroup>

</LinearLayout>

</LinearLayout>

<Button
android:id="@+id/startButtonId"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="420dp"
android:text="PK"
tools:layout_editor_absoluteY="1dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="480dp"
android:orientation="horizontal">

<TextView
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:text="结果:"
android:textSize="20dp"/>

<TextView
android:id="@+id/resultId"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:text=""
android:textSize="20dp"/>
</LinearLayout>

</android.support.design.widget.CoordinatorLayout>
Binary file added soft1614080902318/pk1.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 soft1614080902318/pk2.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 soft1614080902318/pk3.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 soft1614080902318/pkmain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions soft1614080902318/report/report1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 第一次实验

## 1.实验目标
(1)学习和搭建开发环境Android Studio;<br>
(2)了解github网站的功能及提交的基本的要求;<br>
(3)安装git,掌握git的提交,修改等功能;

## 2.实验步骤
(1)下载git,运行git.exe并安装,打开git bash<br>
(2)登录自己的账号后fork加入Git项目<br>
(3)进入本地磁盘cd e: ,将项目克隆到本地磁盘git clone https://github.com/user.name/android-labs-2018.git<br>
(4)进入项目cd android-labs-2018/,创建自己的文件夹soft1614080902318,文件夹里面创建文件Soft1614080902318Activity.java,添加项目截图Soft1614080902318Activity.png
(5)配置自己的信息<br>
git config --global user.email “user.email”<br>
git config --global user.name “user.name”<br>
(6)提交实验内容<br>
git add soft1614080902318/*<br>
git commit -m “#1 第一次实验”<br>
git push<br>
输入用户名、密码<br>
Pull request --> View pull request

## 3.实验结果
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/Soft1614080902318Activity.png)

## 4.实验体会
此次实验比较简单,但是刚开始接触对过程不太熟悉,所以需要耐心慢慢操作几遍,才会对过程有所掌握。
16 changes: 16 additions & 0 deletions soft1614080902318/report/report2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 第二次实验

## 一、实验要求
1、在Issues中创建自己的选题:https://github.com/hzuapps/android-labs-2018/issues ;<br>
2、根据自选题目,编写一个或多个Activity(所有均带上学号前缀,放到自己的Java包下);<br>
3、将标题设置为自己的学号+对应的功能或题目;<br>
4、根据自己选择的题目实现Activity中导航、调用等功能(选做)。

## 二、实验步骤
1、在Issues中创建选题:猜拳小游戏,并设计两个小功能<br>
2、打开Android studio创建项目,项目名任意,包名为edu.hzuapps.androidlabs.soft1614080902318,Activity Name为Soft1614080902318Activity。修改res/values/strings.xml中的app_name为自己app的名字。<br>
3、在项目处右键,找到文件存放路径,把java、res、AndroidManifest.xml文件夹复制到本地磁盘中自己的文件夹soft1614080902318<br>
4、提交实验内容

## 三、实验体会
本次实验做完后发现挺简单的,就是一开始不熟悉流程反复操作了很多遍,经过多次操作后更好地掌握了本次实验。<br>
22 changes: 22 additions & 0 deletions soft1614080902318/report/report3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 第三次实验

## 一、实验目标
1、将图片放入界面中<br>
2、实现Activity间的跳转

## 二、实验步骤
1、在drawable中添加所需图片 <br>
2、在layout中对应的xml文件设置ImageView节点,将图片导入,并调整图片的大小和位置;设置Button节点并调整按钮的大小和位置<br>
3、在Activity文件中实现OnClickListener接口,重写onClick方法,调用startActivity执行跳转到目标页面;在onCreate方法中通过findViewById获取监听组件并设置监听<br>
4、编译、运行程序,在虚拟机中进行效果测试并截图<br>
5、提交实验内容

## 三、实验结果
* 实验截图1:初始界面<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/%233/main.png)<br>

* 实验截图2:游戏界面<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/%233/pk.png)<br>

## 四、实验体会
* 完成这个实验首先要去找资料或视频学习最基本的知识点,理解安卓的语法和各组件的功能作用及使用方法,在不断尝试中摸索清楚具体该怎么做。
41 changes: 41 additions & 0 deletions soft1614080902318/report/report4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 第四次实验

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

## 二、实验内容
1.使用一种布局方式,设计所选题目的界面<br>
2.通过控件ID获取界面对象,执行相关操作<br>
3.实现界面控件的事件处理,例如点击按钮

## 三、实验步骤
1、在drawbale中添加界面所需的两张图片<br>
2、使用LinearLayout布局,设置ImageView节点、TextView节点、RadioButton节点、Button节点并调整节点的大小和位置<br>
3、在Activity中实现OnClickListener,重写onClick方法,通过findViewById获取相应组件及其值、获取监听组件并设置监听<br>
4、编译、运行程序,在虚拟机中进行效果测试,点击两个玩家出拳的单选框后,点击pk按钮执行输赢判断,判断结果输出到界面中<br>
5、提交实验内容

## 四、实验截图
* 游戏初始界面<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/pkmain.png)<br>

* 游戏执行界面1<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/pk1.png)<br>

* 游戏执行界面2<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/pk2.png)<br>

* 游戏执行界面3<br>
![image](https://github.com/linwt/android-labs-2018/blob/master/soft1614080902318/pk3.png)<br>

## 五、实验体会
本次实验是对页面布局的综合操作,首先要清各组件间的相互位置关系、与整体布局的包含关系,学习理解基本知识后便可对界面进行设计调整。通过本次实验,对页面布局的用法有了更好地理解与掌握,也能很好地使用各组件并发挥其功能。







0 comments on commit 8165091

Please sign in to comment.