image.png
image.png
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<EditText
android:id="@+id/diqu"
android:paddingTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入地区"/>
<EditText
android:id="@+id/jiedao"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入街道"
android:layout_below="@+id/diqu"/>
<EditText
android:id="@+id/dizhi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入详细地址"
android:layout_below="@+id/jiedao"/>
<EditText
android:id="@+id/xingming"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入姓名"
android:layout_below="@+id/dizhi"/>
<EditText
android:id="@+id/dianhua"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入联系人电话"
android:layout_below="@+id/xingming"/>
<EditText
android:id="@+id/youbian"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请输入邮政编码"
android:layout_below="@+id/dianhua"/>
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
android:text="提交"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AddressActivity">
<ImageView
android:id="@+id/top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/a"/>
<TextView
android:layout_below="@+id/top"
android:id="@+id/name1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/phone1"
android:layout_below="@+id/name1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:layout_below="@+id/phone1"
android:id="@+id/size1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button=findViewById(R.id.btn);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String dizhi=((EditText)findViewById(R.id.dizhi)).getText().toString();
String xingming=((EditText)findViewById(R.id.xingming)).getText().toString();
String youbian=((EditText)findViewById(R.id.youbian)).getText().toString();
String dianhua=((EditText)findViewById(R.id.dianhua)).getText().toString();
String diqu=((EditText)findViewById(R.id.diqu)).getText().toString();
String jiedao=((EditText)findViewById(R.id.jiedao)).getText().toString();
if(!"".equals(dizhi)&&!"".equals(xingming)&&!"".equals(youbian)
&&!"".equals(dianhua) &&!"".equals(diqu)&&!"".equals(jiedao)){
Intent intent=new Intent(MainActivity.this,AddressActivity.class);
Bundle bundle=new Bundle();
bundle.putCharSequence("name",xingming);
bundle.putCharSequence("phone",dianhua);
bundle.putCharSequence("youbian",youbian);
bundle.putCharSequence("diqu",diqu);
bundle.putCharSequence("dizhi",dizhi);
bundle.putCharSequence("jiedao",jiedao);
intent.putExtras(bundle);
startActivity(intent);
}else{
Toast.makeText(MainActivity.this, "输入完整信息", Toast.LENGTH_SHORT).show();
}
}
});
}
}
public class AddressActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_address);
Intent intent=getIntent();
Bundle bundle=intent.getExtras();
String name=bundle.getString("name");
String phone=bundle.getString("phone");
String qita=bundle.getString("dizhi")+bundle.getString("youbian")
+bundle.getString("jiedao");
TextView tv1=findViewById(R.id.name1);
TextView tv2=findViewById(R.id.phone1);
TextView tv3=findViewById(R.id.size1);
tv1.setText(name);
tv2.setText(phone);
tv3.setText(qita);
}
}