Skip to content

Commit 222ee94

Browse files
authored
Merge pull request #240 from erdongxin/master
#2 #59 第二次作业
2 parents 3722e65 + 594cac7 commit 222ee94

File tree

5 files changed

+221
-1
lines changed

5 files changed

+221
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package edu.hzuapps.androidlabs.homeworks.net1414080903122;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
import android.widget.Button;
8+
import android.widget.EditText;
9+
import android.widget.RadioButton;
10+
import edu.hzuapps.androidlabs.R;
11+
12+
public class Activity01 extends AppCompatActivity {
13+
14+
private RadioButton manRadio;
15+
private RadioButton womanRadio;
16+
private EditText et_password;
17+
private Button btn_send;
18+
private EditText et_name;
19+
20+
@Override
21+
protected void onCreate(Bundle savedInstanceState) {
22+
super.onCreate(savedInstanceState);
23+
setContentView(R.layout.activity_01);
24+
25+
et_name=(EditText) findViewById(R.id.et_name);
26+
et_password=(EditText) findViewById(R.id.et_password);
27+
btn_send=(Button) findViewById(R.id.btn_send);
28+
manRadio=(RadioButton)findViewById(R.id.radioMale);
29+
womanRadio=(RadioButton)findViewById(R.id.radioFemale);
30+
btn_send=(Button)findViewById(R.id.btn_send);
31+
32+
btn_send.setOnClickListener(new View.OnClickListener() {
33+
34+
public void onClick(View v) {
35+
passDate();
36+
}
37+
}
38+
);
39+
}
40+
41+
public void passDate(){
42+
//启动A2
43+
Intent intent=new Intent(this,Activity02.class);
44+
//存入数据到Intent对象
45+
intent.putExtra("name",et_name.getText().toString().trim());
46+
intent.putExtra("password",et_password.getText().toString().trim());
47+
String str="";
48+
if(manRadio.isChecked()){
49+
str="男";
50+
}else if(womanRadio.isChecked()){
51+
str="女";
52+
}
53+
intent.putExtra("sex",str);
54+
startActivity(intent);
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package edu.hzuapps.androidlabs.homeworks.net1414080903122;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.widget.TextView;
7+
8+
import edu.hzuapps.androidlabs.R;
9+
10+
public class Activity02 extends AppCompatActivity {
11+
private TextView tv_name,tv_password,tv_sex;
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
setContentView(R.layout.activity_02);
17+
//获取intent对象
18+
Intent intent=getIntent();
19+
//取出参数
20+
String name=intent.getStringExtra("name");
21+
String password=intent.getStringExtra("password");
22+
String sex=intent.getStringExtra("sex");
23+
tv_name=(TextView)findViewById(R.id.tv_name);
24+
tv_password=(TextView)findViewById(R.id.tv_password);
25+
tv_sex=(TextView)findViewById(R.id.tv_sex);
26+
tv_name.setText("用户名:"+ name);
27+
tv_password.setText("密码:"+ password);
28+
tv_sex.setText("性别:"+ sex);
29+
30+
}
31+
}

AndroidLabs/app/src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903122/Net1414080903122Activity.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package edu.hzuapps.androidlabs.homworks.net1414080903122;
1+
package edu.hzuapps.androidlabs.homeworks.net1414080903122;
22

33
import android.support.v7.app.AppCompatActivity;
44
import android.os.Bundle;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
4+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
5+
xmlns:tools="http://schemas.android.com/tools"
6+
android:id="@+id/activity_01"
7+
android:layout_width="match_parent"
8+
android:layout_height="match_parent"
9+
android:orientation="vertical">
10+
11+
<LinearLayout
12+
android:id="@+id/regist_username"
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
16+
android:layout_marginLeft="10dp"
17+
android:layout_marginRight="10dp"
18+
android:layout_marginTop="22dp"
19+
android:orientation="horizontal">
20+
21+
<TextView
22+
android:layout_width="80dp"
23+
android:layout_height="wrap_content"
24+
android:gravity="right"
25+
android:paddingRight="5dp"
26+
android:text="用户名:" />
27+
28+
<EditText
29+
android:id="@+id/et_name"
30+
android:layout_width="match_parent"
31+
android:layout_height="wrap_content"
32+
android:hint="请输入您的用户名"
33+
android:inputType="textPersonName"
34+
android:textSize="14dp" />
35+
36+
</LinearLayout>
37+
38+
<LinearLayout
39+
android:id="@+id/regist_password"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"
42+
android:layout_below="@+id/regist_username"
43+
44+
android:layout_marginLeft="10dp"
45+
android:layout_marginRight="10dp"
46+
android:layout_marginTop="5dp"
47+
android:orientation="horizontal">
48+
49+
<TextView
50+
android:layout_width="80dp"
51+
android:layout_height="wrap_content"
52+
android:gravity="right"
53+
android:paddingRight="5dp"
54+
android:text="密 码:" />
55+
56+
<EditText
57+
android:id="@+id/et_password"
58+
android:layout_width="match_parent"
59+
android:layout_height="wrap_content"
60+
android:hint="请输入您的密码"
61+
android:inputType="textPassword"
62+
android:textSize="14dp" />
63+
64+
</LinearLayout>
65+
66+
<RadioGroup
67+
android:id="@+id/radioGroup"
68+
android:layout_width="wrap_content"
69+
android:layout_height="wrap_content"
70+
android:layout_below="@+id/regist_password"
71+
android:layout_marginLeft="30dp"
72+
android:orientation="horizontal"
73+
android:contentDescription="性别">
74+
75+
<RadioButton
76+
android:id="@+id/radioMale"
77+
android:layout_width="wrap_content"
78+
android:layout_height="wrap_content"
79+
android:checked="true"
80+
android:text="" />
81+
82+
<RadioButton
83+
android:id="@+id/radioFemale"
84+
android:layout_width="wrap_content"
85+
android:layout_height="wrap_content"
86+
android:text="" />
87+
</RadioGroup>
88+
89+
<Button
90+
android:id="@+id/btn_send"
91+
android:layout_width="wrap_content"
92+
android:layout_height="wrap_content"
93+
android:layout_below="@+id/radioGroup"
94+
android:layout_centerHorizontal="true"
95+
android:layout_marginTop="36dp"
96+
android:text="提交用户信息"/>
97+
98+
99+
</RelativeLayout>
100+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:id="@+id/activity_02"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical"
8+
tools:context="edu.hzuapps.androidlabs.homeworks.net1414080903122.Activity02">
9+
10+
<TextView
11+
android:layout_width="wrap_content"
12+
android:layout_height="wrap_content"
13+
android:gravity="center"
14+
android:layout_marginTop="10dp"
15+
android:textSize="20dp"
16+
android:id="@+id/tv_name" />
17+
18+
<TextView
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:gravity="center"
22+
android:layout_marginTop="10dp"
23+
android:textSize="20dp"
24+
android:id="@+id/tv_password" />
25+
26+
<TextView
27+
android:layout_width="wrap_content"
28+
android:layout_height="wrap_content"
29+
android:gravity="center"
30+
android:layout_marginTop="10dp"
31+
android:textSize="20dp"
32+
android:id="@+id/tv_sex" />
33+
</LinearLayout>

0 commit comments

Comments
 (0)