Skip to content

Commit

Permalink
hzuapps#4 hzuapps#957 第四次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyangyang2017 committed May 8, 2018
1 parent 4c2df60 commit ea8a5ae
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,96 @@
package edu.hzuapps.androidlabs.soft1614080902221;

import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.widget.AbsoluteLayout;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

public class Activity2 extends AppCompatActivity {
private EditText etText = null;
private RadioGroup sex_rg = null;
private RadioGroup gameCharacters = null;
private TextView text2 = null;
private Button okButton = null;
private Button resetButton = null;
private Button goButton = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();// 隐藏ActionBar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//remove notification bar 即全屏
setContentView(R.layout.activity_2);
initView();
}

private void initView() {
etText = (EditText) findViewById(R.id.edText1);
sex_rg = (RadioGroup) findViewById(R.id.sex_rg);
gameCharacters = (RadioGroup) findViewById(R.id.gameCharacters);
text2 = (TextView) findViewById(R.id.text2);
okButton = (Button) findViewById(R.id.okButton);
resetButton = (Button) findViewById(R.id.resetButton);
goButton = (Button) findViewById(R.id.goButton);
goButton.setVisibility(View.INVISIBLE);

okButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String strPersonName = etText.getText().toString();

int sex = sex_rg.getCheckedRadioButtonId();
RadioButton sex_rb = (RadioButton) findViewById(sex);
String strSex = sex_rb.getText().toString();

int gameName = gameCharacters.getCheckedRadioButtonId();
RadioButton gameName_rb = (RadioButton) findViewById(gameName);
String strGameName = gameName_rb.getText().toString();

if (strPersonName.equals("")) {
goButton.setVisibility(View.INVISIBLE);
Toast.makeText(Activity2.this, "请输入您的名称", Toast.LENGTH_SHORT).show();
//text2.setText("请输入您的名称!!!");
} else {
goButton.setVisibility(View.VISIBLE);
text2.setText("亲爱的" + strPersonName + "玩家,\n" + "性别:" + strSex + "\n" +
"你选择的角色:" + strGameName);
}


}
});

resetButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

etText.setText("");

RadioButton sex_rb = (RadioButton) findViewById(R.id.male_rb);
sex_rb.setChecked(true);

RadioButton gameName_rb = (RadioButton) findViewById(R.id.muLing);
gameName_rb.setChecked(true);

text2.setText("");
goButton.setVisibility(View.INVISIBLE);


}
});


}


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
public class Soft1614080902221Activity extends AppCompatActivity {

private Button startButton = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();// 隐藏ActionBar
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//remove notification bar 即全屏
setContentView(R.layout.activity_soft1614080902221);

startButton = (Button)findViewById(R.id.startButton);
startButton.setOnClickListener(new OnClickListener(){
startButton = (Button) findViewById(R.id.startButton);
startButton.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
Intent intent = new Intent(Soft1614080902221Activity.this,Activity2.class);
startActivity(intent);
Intent intent = new Intent(Soft1614080902221Activity.this, Activity2.class);
startActivity(intent);
}
} );
});


}
Expand Down
127 changes: 122 additions & 5 deletions soft1614080902221/app/src/main/res/layout/activity_2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,129 @@
android:layout_height="match_parent"
tools:context=".Activity2">

<ImageView
android:id="@+id/pic2"
android:src="@drawable/picture2"
android:scaleType="centerCrop"

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="wrap_content"
android:orientation="vertical">

<EditText
android:id="@+id/edText1"
android:layout_width="match_parent"
android:layout_height="70dp"
android:hint="请输入您的名称" />

<RadioGroup
android:id="@+id/sex_rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<RadioButton
android:id="@+id/male_rb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text=""
android:textSize="20dp" />

<RadioButton
android:id="@+id/famale_rb"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:textSize="20dp" />
</RadioGroup>


<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="请选择游戏角色:"
android:textSize="20dp" />


<RadioGroup
android:id="@+id/gameCharacters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<RadioButton
android:id="@+id/muLing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="true"
android:text="慕灵"
android:textSize="20dp" />

<RadioButton
android:id="@+id/ruoYang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="若烟"
android:textSize="20dp" />

<RadioButton
android:id="@+id/wanghai"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="宛海"
android:textSize="20dp" />

</RadioGroup>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">

<Button
android:id="@+id/okButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"
android:textSize="12dp" />

<Button
android:id="@+id/resetButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="重置"
android:textSize="12dp" />

</LinearLayout>

<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text=""
android:textColor="#e31d1d"
android:textSize="20dp" />

<Button
android:id="@+id/goButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="30dp"
android:text="GO!"
android:textSize="20dp" />


</LinearLayout>


</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
android:src="@drawable/picture1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
Expand Down
6 changes: 0 additions & 6 deletions soft1614080902221/app/src/main/res/values/colors.xml

This file was deleted.

3 changes: 0 additions & 3 deletions soft1614080902221/app/src/main/res/values/dimens.xml

This file was deleted.

20 changes: 0 additions & 20 deletions soft1614080902221/app/src/main/res/values/styles.xml

This file was deleted.

Binary file added soft1614080902221/第4次实验截图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 soft1614080902221/第4次实验截图2.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 soft1614080902221/第4次实验截图3.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 soft1614080902221/第4次实验截图4.png
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 ea8a5ae

Please sign in to comment.