Android作业10/07
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的更多相关文章
- 团队作业10——事后分析(Beta版本)
		
团队作业10--事后分析(Beta版本) 目录 一.设想与目标 二.计划 三.资源 四.变更管理 五.设计与实现 六.测试与发布 七.总结 八.图片和贡献分分配 一.设想和目标 1.我们的软件要解决什 ...
 - 【2017集美大学1412软工实践_助教博客】团队作业10——项目复审与事后分析(Beta版本)
		
写在前面的话 转眼轰轰烈烈本学期的软工实践就结束了,这个过程中想必在熬夜敲代码,激烈讨论中留下诸多回忆的同时,也收获了不少.恭喜所有团队完成了本阶段冲刺,此外,由于大家的贡献分给的都很平均,将个人贡献 ...
 - 【1414软工助教】团队作业10——复审与事后分析(Beta版本) 得分榜
		
题目 团队作业10--复审与事后分析(Beta版本) 往期成绩 个人作业1:四则运算控制台 结对项目1:GUI 个人作业2:案例分析 结对项目2:单元测试 团队作业1:团队展示 团队作业2:需求分析& ...
 - 简单计算器 安卓 Android 作业
		
Android老师布置的课程作业——简单计算器 功能要求实现四则运算,参考界面见下图: 首先给各位老铁提供apk安装包以及项目压缩包,略表诚意~ github地址:https://github.com ...
 - 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 ...
 - 【集美大学1411_助教博客】团队作业10——项目复审与事后分析(Beta版本)
		
写在前面的话 软件工程课结束了,大家开心吗?是不是再也不用熬夜写代码了?如果这门课你真的熬夜写代码了,相信你一定有收获,如果这门课结束了你觉得是自己一个全新的开始,那么这门课的意义就实现了.团队作业全 ...
 - 团队作业10——项目复审与事后分析(Beta版本)
		
油炸咸鱼24点APP 团队作业10--事后诸葛亮分析; 团队作业10--Beta阶段项目复审;
 - 团队作业10——复审和事后分析(Beta版本)
		
团队作业10--事后分析(Beta版本) http://www.cnblogs.com/newteam6/p/6953992.html 团队作业10--复审(Beta版本) http://www.cn ...
 - C语言|博客作业10
		
问题 回答 C语言 博客作业10 这个作业要求在哪里 作业要求 我在这个课程的目标是 熟练循环语句的用法 这个作业在哪个具体方面帮助我实现目标 pta作业 参考文献 <C语言程序设计> 1 ...
 
随机推荐
- Vue.js学习(八)—— 树形结构下拉框组件vue-treeselect
			
vue-treeselect是一个多选组件,具有对Vue.js的嵌套选项支持. 具有嵌套选项支持的单个和多个选择 模糊匹配 异步搜索 延迟加载(仅在需要时加载深层选项的数据) 键盘支持(使用Arrow ...
 - npm 进阶命令知多少(一)
			
npm命令知多少(一) 前言 作为前端模块化扎展现形式的npm包,已经在前端开发中不可或缺,熟练掌握npm相关内容,也是前端开发者的一门必修课,那么除了npm publish这类常见内容之外,还有哪些 ...
 - Activiti7 查询用户任务列表
			
package com.itheima.activiti; import org.activiti.engine.ProcessEngine; import org.activiti.engine.P ...
 - Zookeeper高级
			
1.1. 一致性协议概述 前面已经讨论过,在分布式环境下,有很多不确定性因素,故障随时都回发生,也讲了CAP理论,BASE理论 我们希望达到,在分布式环境下能搭建一个高可用的,且数据高一致性的服务,目 ...
 - 深入理解Java中的装箱与拆箱
			
一.Java数据类型 1.在说装箱与拆箱之前,先说一下Java的基本数据类型,Java从数据类型上可以划分为值类型与引用类型,值类型是四类八种,分别是: 整数型:byte̵,short̵,int̵,l ...
 - 关于json序列化相关代码
			
自己写的一个 /// <summary> /// 序列化JSON,返回string /// </summary> /// <param name="dt&quo ...
 - 一起来读官方文档-----SpringIOC(04)
			
1.4.2.依赖性和详细配置 如上一节所述,您可以将bean属性和构造函数参数定义为对其他托管bean(协作者)的引用或内联定义的值.Spring的基于XML的配置元数据为此目的在其和元素中支持子元素 ...
 - [二叉树-根到叶的子路径]路径总和 III (两层递归)
			
题目437. 路径总和 III 给定一个二叉树,它的每个结点都存放着一个整数值. 找出路径和等于给定数值的路径总数. 路径不需要从根节点开始,也不需要在叶子节点结束,但是路径方向必须是向下的(只能从父 ...
 - charles常用功能 request和response(简单的操作)
			
先介绍一个修改request请求参数值的方法吧 第一步: 拷贝完成后还需要配置一下: 先添加一个: 然后下一步: 最后点击OK,就可以开始操作request和response数据了 先修改reques ...
 - Node.js 从零开发 web server博客项目[项目介绍]
			
web server博客项目 Node.js 从零开发 web server博客项目[项目介绍] Node.js 从零开发 web server博客项目[接口] Node.js 从零开发 web se ...