-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #290 from zhangguowei/master
- Loading branch information
Showing
4 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...src/main/java/edu/hzuapps/androidlabs/homeworks/net1414080903121/Net1414080903121Get.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903121; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.widget.TextView; | ||
import edu.hzuapps.androidlabs.R; | ||
|
||
/** | ||
* Created by 1 on 2017/5/4. | ||
*/ | ||
|
||
public class Net1414080903121Get extends AppCompatActivity { | ||
private TextView tv_name,tv_password,tv_sex; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903121get); | ||
//获取Intent对象 | ||
Intent intent = getIntent(); | ||
//取出key对应的value值 | ||
String name = intent.getStringExtra("name"); | ||
String password = intent.getStringExtra("password"); | ||
String sex = intent.getStringExtra("sex"); | ||
tv_name = (TextView) findViewById(R.id.tv_name); | ||
tv_password = (TextView) findViewById(R.id.tv_password); | ||
tv_sex = (TextView) findViewById(R.id.tv_sex); | ||
tv_name.setText("用户名: " + name); | ||
tv_password.setText("密码: " + password); | ||
tv_sex.setText("性别: " + sex); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ain/java/edu/hzuapps/androidlabs/homeworks/net1414080903121/Net1414080903121Register.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903121; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.RadioButton; | ||
|
||
import edu.hzuapps.androidlabs.R; | ||
|
||
/** | ||
* Created by 1 on 2017/5/4. | ||
*/ | ||
|
||
public class Net1414080903121Register extends AppCompatActivity { | ||
private RadioButton manRadio; | ||
private RadioButton womanRadio; | ||
private EditText et_password; | ||
private Button btn_send; | ||
private EditText et_name; | ||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_net1414080903121register); | ||
et_name = (EditText) findViewById(R.id.et_name); | ||
et_password = (EditText) findViewById(R.id.et_password); | ||
btn_send = (Button) findViewById(R.id.btn_send); | ||
manRadio = (RadioButton) findViewById(R.id.radioMale); | ||
womanRadio = (RadioButton) findViewById(R.id.radioFemale); | ||
btn_send = (Button) findViewById(R.id.btn_send); | ||
//点击注册按钮进行数据传递 | ||
btn_send.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
passDate(); | ||
} | ||
}); | ||
} | ||
//传递数据 | ||
public void passDate() { | ||
//创建Intent对象,启动getRegister_net1414080903121 | ||
Intent intent = new Intent(this,Net1414080903121Get.class); | ||
//将数据存入Intent对象 | ||
intent.putExtra("name",et_name.getText().toString().trim()); | ||
intent.putExtra("password",et_password.getText().toString().trim()); | ||
String str=""; | ||
if (manRadio.isChecked()){ | ||
str = "男"; | ||
}else if (womanRadio.isChecked()){ | ||
str = "女"; | ||
} | ||
intent.putExtra("sex",str); | ||
startActivity(intent); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
AndroidLabs/app/src/main/res/layout/activity_net1414080903121get.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout 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" | ||
android:orientation="vertical"> | ||
<TextView | ||
android:id="@+id/tv_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="10dp" | ||
android:textSize="20sp"/> | ||
<TextView | ||
android:id="@+id/tv_password" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="10dp" | ||
android:textSize="20sp"/> | ||
<TextView | ||
android:id="@+id/tv_sex" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:layout_marginStart="20dp" | ||
android:layout_marginTop="10dp" | ||
android:textSize="20sp"/> | ||
</LinearLayout> |
91 changes: 91 additions & 0 deletions
91
AndroidLabs/app/src/main/res/layout/activity_net1414080903121register.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<LinearLayout | ||
android:id="@+id/regist_username" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginLeft="10dp" | ||
android:layout_marginRight="10dp" | ||
android:layout_marginTop="22dp" | ||
android:orientation="horizontal" | ||
> | ||
|
||
<TextView | ||
android:layout_width="80dp" | ||
android:layout_height="wrap_content" | ||
android:text="用户名:" | ||
android:gravity="end" | ||
android:paddingEnd="5dp" /> | ||
|
||
<EditText | ||
android:id="@+id/et_name" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" | ||
android:hint="请输入你的用户名" /> | ||
</LinearLayout> | ||
|
||
<LinearLayout | ||
android:id="@+id/regist_password" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/regist_username" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginLeft="10dp" | ||
android:layout_marginRight="10dp" | ||
android:layout_marginTop="5dp" | ||
android:orientation="horizontal" | ||
> | ||
<TextView | ||
android:layout_width="80dp" | ||
android:layout_height="wrap_content" | ||
android:text="密 码:" | ||
android:gravity="end" | ||
|
||
android:paddingEnd="5dp" /> | ||
|
||
<EditText | ||
android:id="@+id/et_password" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:textSize="14sp" | ||
android:inputType="textPassword" | ||
android:text="请输入你的密码" /> | ||
</LinearLayout> | ||
|
||
<RadioGroup | ||
android:id="@+id/radioGroup" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:orientation="horizontal" | ||
android:contentDescription="性别" | ||
android:layout_marginStart="30dp" | ||
android:layout_below="@+id/regist_password"> | ||
|
||
<RadioButton | ||
android:id="@+id/radioMale" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="男" | ||
android:checked="true" /> | ||
|
||
<RadioButton | ||
android:id="@+id/radioFemale" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="女" /> | ||
</RadioGroup> | ||
<Button | ||
android:id="@+id/btn_send" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@+id/radioGroup" | ||
android:layout_centerHorizontal="true" | ||
android:layout_marginTop="20dp" | ||
android:background="@android:drawable/checkbox_off_background" | ||
android:text="注册" /> | ||
</RelativeLayout> |