diff --git a/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Activity2.java b/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Activity2.java index 9ebb67f06..a09bebec4 100644 --- a/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Activity2.java +++ b/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Activity2.java @@ -1,10 +1,28 @@ 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) { @@ -12,5 +30,67 @@ protected void onCreate(Bundle 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); + + + } + }); + + + } + + } diff --git a/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Soft1614080902221Activity.java b/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Soft1614080902221Activity.java index 94e0a7a2f..545d06fc0 100644 --- a/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Soft1614080902221Activity.java +++ b/soft1614080902221/app/src/main/java/edu/hzuapps/androidlabs/soft1614080902221/Soft1614080902221Activity.java @@ -11,6 +11,7 @@ public class Soft1614080902221Activity extends AppCompatActivity { private Button startButton = null; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -18,15 +19,15 @@ protected void onCreate(Bundle savedInstanceState) { 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); } - } ); + }); } diff --git a/soft1614080902221/app/src/main/res/layout/activity_2.xml b/soft1614080902221/app/src/main/res/layout/activity_2.xml index b7ea61cac..263f8310d 100644 --- a/soft1614080902221/app/src/main/res/layout/activity_2.xml +++ b/soft1614080902221/app/src/main/res/layout/activity_2.xml @@ -6,12 +6,129 @@ android:layout_height="match_parent" tools:context=".Activity2"> - + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + +