1.多个Activity界面实现数据的传递

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity"
android:background="#565968"> <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="用户名:"/> <EditText
android:id="@+id/et1"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tv1"
/> <TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="密码:"
android:layout_below="@id/tv1"/> <EditText
android:id="@+id/et2"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_below="@id/tv1"
android:layout_toRightOf="@id/tv1"
android:layout_marginTop="10dp"
/> <TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="性别:"
android:layout_below="@id/tv2"
android:layout_marginTop="29dp"/> <RadioGroup
android:id="@+id/rg1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/tv2"
android:layout_toRightOf="@id/tv3"
android:layout_marginTop="25dp"> <RadioButton
android:id="@+id/boy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="男"/> <RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女"/> </RadioGroup> <TextView
android:id="@+id/tv4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="爱好:"
android:layout_below="@id/tv3"
android:layout_marginTop="29dp"/> <CheckBox
android:id="@+id/ping-pong"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="乒乓球"
android:textSize="12dp"
android:layout_below="@id/tv4"
/> <CheckBox
android:id="@+id/football"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="足球"
android:textSize="12dp"
android:layout_marginLeft="75dp"
android:layout_below="@id/tv4"
/> <CheckBox
android:id="@+id/volleyball"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="排球"
android:textSize="12dp"
android:layout_marginLeft="135dp"
android:layout_below="@id/tv4"
/> <CheckBox
android:id="@+id/badminton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="羽毛球"
android:textSize="12dp"
android:layout_marginLeft="195dp"
android:layout_below="@id/tv4"
/> <CheckBox
android:id="@+id/basketball"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="篮球"
android:textSize="12dp"
android:layout_marginLeft="265dp"
android:layout_below="@id/tv4"
/> <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="注册"
android:textColor="#896526"
android:layout_below="@id/tv4"
android:layout_marginTop="100dp"
android:layout_marginLeft="120dp"
android:onClick="click"/> </RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout>

  

package com.example.myhomework4;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup; public class MainActivity extends AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
} public void click(View view){ Intent it1=new Intent(this,SecondActivity.class);
String username = ((EditText)findViewById(R.id.et1)).getText().toString();
String password = ((EditText)findViewById(R.id.et2)).getText().toString();
it1.putExtra("username", username);
it1.putExtra("password", password); RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rg1);
int id = radioGroup.getCheckedRadioButtonId();
if(id == R.id.boy)
{
it1.putExtra("sex","男");
}
else
{
it1.putExtra("sex","女");
} CheckBox checkBox1 = (CheckBox)findViewById(R.id.ping_pong);
CheckBox checkBox2 = (CheckBox)findViewById(R.id.football);
CheckBox checkBox3 = (CheckBox)findViewById(R.id.volleyball);
CheckBox checkBox4 = (CheckBox)findViewById(R.id.badminton);
CheckBox checkBox5 = (CheckBox)findViewById(R.id.basketball);
if(checkBox1.isChecked()) {
it1.putExtra("ping-pong","乒乓球");
}
if (checkBox2.isChecked()) {
it1.putExtra("football","足球");
}
if(checkBox3.isChecked()) {
it1.putExtra("volleyball", "排球");
}
if(checkBox4.isChecked()) {
it1.putExtra("badminton", "羽毛球");
}
if (checkBox5.isChecked()){
it1.putExtra("basketball","篮球");
} startActivity(it1);
} }

  

package com.example.myhomework4;

import android.app.Activity;
import android.content.Intent;
import android.widget.Toast; public class SecondActivity extends Activity { @Override
protected void onStart() {
super.onStart();
Intent intent = getIntent();
String username = intent.getStringExtra("username");
String password = intent.getStringExtra("password");
String sex = intent.getStringExtra("sex");
String pingpong ="";
String football ="";
String volleyball ="";
String badminton ="";
String basketball ="";
if(intent.getStringExtra("ping-pong") != null)
{
pingpong = intent.getStringExtra("ping-pong");
}
if(intent.getStringExtra("football") != null)
{
football = intent.getStringExtra("football");
}
if(intent.getStringExtra("volleyball") != null)
{
volleyball = intent.getStringExtra("volleyball");
}
if(intent.getStringExtra("badminton") != null)
{
badminton = intent.getStringExtra("badminton");
}
if(intent.getStringExtra("basketball") != null)
{
basketball = intent.getStringExtra("basketball");
} Toast.makeText(this, "您好,您的注册信息是:\n\n" + "用户名:" + username + "\n密码:" + password + "\n性别:"
+ sex + "\n爱好:" + pingpong + football + volleyball + badminton + basketball, Toast.LENGTH_SHORT).show();
}
}

  

Android作业10/07的更多相关文章

  1. 团队作业10——事后分析(Beta版本)

    团队作业10--事后分析(Beta版本) 目录 一.设想与目标 二.计划 三.资源 四.变更管理 五.设计与实现 六.测试与发布 七.总结 八.图片和贡献分分配 一.设想和目标 1.我们的软件要解决什 ...

  2. 【2017集美大学1412软工实践_助教博客】团队作业10——项目复审与事后分析(Beta版本)

    写在前面的话 转眼轰轰烈烈本学期的软工实践就结束了,这个过程中想必在熬夜敲代码,激烈讨论中留下诸多回忆的同时,也收获了不少.恭喜所有团队完成了本阶段冲刺,此外,由于大家的贡献分给的都很平均,将个人贡献 ...

  3. 【1414软工助教】团队作业10——复审与事后分析(Beta版本) 得分榜

    题目 团队作业10--复审与事后分析(Beta版本) 往期成绩 个人作业1:四则运算控制台 结对项目1:GUI 个人作业2:案例分析 结对项目2:单元测试 团队作业1:团队展示 团队作业2:需求分析& ...

  4. 简单计算器 安卓 Android 作业

    Android老师布置的课程作业——简单计算器 功能要求实现四则运算,参考界面见下图: 首先给各位老铁提供apk安装包以及项目压缩包,略表诚意~ github地址:https://github.com ...

  5. Xamarin.Android 4.10.01068 & Xamarin.iOS 1.8.361

    Xamarin.Android 4.10.01068 & Xamarin.iOS 1.8.361 NEW support for Visual Studio 2013 & Portab ...

  6. 【集美大学1411_助教博客】团队作业10——项目复审与事后分析(Beta版本)

    写在前面的话 软件工程课结束了,大家开心吗?是不是再也不用熬夜写代码了?如果这门课你真的熬夜写代码了,相信你一定有收获,如果这门课结束了你觉得是自己一个全新的开始,那么这门课的意义就实现了.团队作业全 ...

  7. 团队作业10——项目复审与事后分析(Beta版本)

    油炸咸鱼24点APP 团队作业10--事后诸葛亮分析; 团队作业10--Beta阶段项目复审;

  8. 团队作业10——复审和事后分析(Beta版本)

    团队作业10--事后分析(Beta版本) http://www.cnblogs.com/newteam6/p/6953992.html 团队作业10--复审(Beta版本) http://www.cn ...

  9. C语言|博客作业10

    问题 回答 C语言 博客作业10 这个作业要求在哪里 作业要求 我在这个课程的目标是 熟练循环语句的用法 这个作业在哪个具体方面帮助我实现目标 pta作业 参考文献 <C语言程序设计> 1 ...

随机推荐

  1. 高可用集群corosync+pacemaker之crmsh使用(二)

    上一篇博客我们聊到了crmsh的安装以及配置一个资源到corosync+pacemaker高可用集群上的相关命令的用法,回顾请参考https://www.cnblogs.com/qiuhom-1874 ...

  2. 用android studio多渠道打包

    1. 官方教程 https://developer.android.com/studio/build/build-variants.html 2. 设置Build Types参数 打开 Project ...

  3. vant ui TabBar封装

    TabBar.vue基本上是放在App.vue里面,都存在 <template> <div id="app"> <home-tab-bar :tar- ...

  4. linux基础一(目录结构)

    一.linux目录结构 1.根目录/下 bin:用户二进制文件,常用命令都在此目录下 sbin;这个目录下的linux命令通常由系统管理员使用 etc:包含所有程序所需的配置文件,以及服务的启动文件 ...

  5. elo system

    今天了解了一下游戏中的PVP模块的实现,大多数的游戏都使用到了ELO算法,刚开始的时候并不清楚这个算法是做什么的,对此开始大量查找有关于ELO算法的资源,功夫不负有心人,总算找到一些有用的资源了. 先 ...

  6. Jack Straws(POJ 1127)

    原题如下: Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5555   Accepted: 2536 ...

  7. HTML -- 表单元素1

    HTML 表单用于搜集不同类型的用户输入. 一.<form> 标签 <form> 标签用于为用户输入创建 HTML 表单. 表单能够包含 input 元素,比如文本字段.复选框 ...

  8. PowerJob 应对庞大任务的锦囊妙计:MapReduce

    本文适合有 Java 基础知识的人群 作者:HelloGitHub-Salieri HelloGitHub 推出的<讲解开源项目>系列.讲解 PowerJob 系列即将接近尾声,本系列的干 ...

  9. Linux实战(11):Centos后期添加网卡配置

    前言 最近在折腾网卡,发现在已装centos上的机器上直接加网卡,开机后在系统中是没有启动的,下面的步骤是启动的过程,大家可以参考一下. 正文 首先我们先看网卡配置目录下的文件跟网卡 查询UUID y ...

  10. 对比ERP解读企业资产管理EAM在电力行业应用

    对比ERP解读企业资产管理EAM在电力行业应用 .关于EAMEAM (Enterprise Asset Management)企业资产管理,是面向固定资产占企业资产主要部分的资产密集型(Capital ...