Android第五次作业


<?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=".MainActivity"> <TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户名:"
android:layout_marginTop="100dp"
android:layout_marginLeft="20dp"/>
<EditText
android:id="@+id/et1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名:"
android:layout_toRightOf="@+id/tv1"
android:layout_alignTop="@id/tv1"
android:layout_marginRight="50dp"/>
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码:"
android:layout_below="@+id/tv1"
android:layout_marginTop="50dp"
android:layout_alignRight="@+id/tv1"/>
<EditText
android:id="@+id/et2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码:"
android:layout_toRightOf="@+id/tv2"
android:layout_below="@+id/tv1"
android:layout_alignTop="@id/tv2"
android:layout_marginRight="50dp"/> <LinearLayout
android:id="@+id/ll_1"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="@+id/et2"
android:orientation="vertical"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp">
<TextView
android:id="@+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="兴趣爱好:" />
<CheckBox
android:id="@+id/cb_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="编程"
android:layout_marginTop="30dp"/>
<CheckBox
android:id="@+id/cb_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下棋" />
<CheckBox
android:id="@+id/cb_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="唱歌" />
</LinearLayout>
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="200dp"
android:layout_below="@+id/et2"
android:onClick="click"
android:text="注册" /> </RelativeLayout>
package com.example.myhomework; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText; public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {
String s1="",s2="",s3="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CheckBox cb1=(CheckBox)findViewById(R.id.cb_1);
CheckBox cb2=(CheckBox)findViewById(R.id.cb_2);
CheckBox cb3=(CheckBox)findViewById(R.id.cb_3);
cb1.setOnCheckedChangeListener(this);
cb2.setOnCheckedChangeListener(this);
cb3.setOnCheckedChangeListener(this); }
public void click(View view){
Intent intent=new Intent();
intent.setClass(MainActivity.this,SecondActivity.class);
String name=((EditText)(findViewById(R.id.et1))).getText().toString();
String account=name;
String text=s1+" "+s2+" "+s3;
intent.putExtra("account",account);
intent.putExtra("text",text);
startActivity(intent);
}
@Override
public void onCheckedChanged(CompoundButton cb, boolean isChecked) {
// TODO Auto-generated method stub
switch (cb.getId()) {
case R.id.cb_1:
if(isChecked)
s1+="编程";
else s1="";
break;
case R.id.cb_2:
if(isChecked)
s2+="下棋";
else s2="";
break;
case R.id.cb_3:
if(isChecked)
s3+="唱歌";
else s3="";
break;
default:
break;
}
} @Override
public void onPointerCaptureChanged(boolean hasCapture) { }
}

<?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=".SecondActivity">
<TextView
android:id="@+id/tv_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="这是界面2"
android:textSize="25sp"
android:textColor="#000000"/> <TextView
android:id="@+id/tv_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="用户名:" />
<TextView
android:id="@+id/tv_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tv_2"
android:layout_alignTop="@id/tv_2"
android:text="" />
<TextView
android:id="@+id/tv_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_2"
android:layout_alignLeft="@id/tv_2"
android:text="兴趣爱好:" /> <TextView
android:id="@+id/tv_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tv_4"
android:layout_alignTop="@id/tv_4"
android:text="" />
<Button
android:id="@+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="150dp"
android:text="我要充值"/>
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_below="@id/btn_1"
android:layout_alignLeft="@id/btn_1"/> </RelativeLayout>
package com.example.myhomework; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView; public class SecondActivity extends AppCompatActivity implements View.OnClickListener { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Intent intent1 = getIntent();
String name = intent1.getStringExtra("account");
((TextView) (findViewById(R.id.tv_3))).setText(name);
Intent intent2 = getIntent();
String text = intent2.getStringExtra("text");
((TextView) (findViewById(R.id.tv_5))).setText(text); findViewById(R.id.btn_1).setOnClickListener(this); } @Override
public void onClick(View view) {
Intent intent = new Intent(this,ThirdActivity.class);
startActivityForResult(intent,1);
} @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==1&&resultCode==2){
String pay=data.getStringExtra("pay");
((TextView)(findViewById(R.id.tv1))).setText(pay);
}
}
}


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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=".ThirdActivity"
android:orientation="vertical">
<TextView
android:id="@+id/tv_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="充值金额为:"
android:textSize="25sp"
android:layout_marginTop="50dp"
android:layout_gravity="center"/>
<Button
android:id="@+id/bt_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="100"
android:layout_gravity="center"/>
<Button
android:id="@+id/bt_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="500"
android:layout_gravity="center"/>
<Button
android:id="@+id/bt_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1000"
android:layout_gravity="center"/>
</LinearLayout>
package com.example.myhomework; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent;
import android.os.Bundle;
import android.view.View; public class ThirdActivity extends AppCompatActivity implements View.OnClickListener { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
findViewById(R.id.bt_1).setOnClickListener(this);
findViewById(R.id.bt_2).setOnClickListener(this);
findViewById(R.id.bt_3).setOnClickListener(this);
} @Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.bt_1:
Intent intent1 = new Intent(this, SecondActivity.class);
intent1.putExtra("pay", "充值金额为:100元");
setResult(2, intent1);
finish();
break;
case R.id.bt_2:
Intent intent2 = new Intent(this, SecondActivity.class);
intent2.putExtra("pay", "充值金额为:500元");
setResult(2, intent2);
finish();
break;
case R.id.bt_3:
Intent intent3 = new Intent(this, SecondActivity.class);
intent3.putExtra("pay", "充值金额为:1000元");
setResult(2, intent3);
finish();
break;
}
} @Override
public void onPointerCaptureChanged(boolean hasCapture) { }
}


Android第五次作业的更多相关文章
- Android第五六周作业
1.返回键实现对话框弹出是否退出应用程序 package com.example.zuoye1; import androidx.appcompat.app.AlertDialog; import a ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum1
题目:团队作业--Alpha冲刺 17秋 软件工程 团队第五次作业 Alpha Scrum1 各个成员在 Alpha 阶段认领的任务 伟航:督促和监督团队进度,协调组内合作 港晨:APP前端页面编写: ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum2
17秋 软件工程 团队第五次作业 Alpha Scrum2 今日完成的任务 杰麟:Java后端的学习: 世强:登录和注册接口编写: 港晨:完成数据库表的设计: 树民.陈翔:完成超级管理员后端框架. 其 ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum3
17秋 软件工程 团队第五次作业 Alpha Scrum3 今日完成的任务 杰麟:java后端学习: 世强:Android的部门基础信息模块的信息显示和对接后台: 港晨:后台管理登陆界面ui设计: 树 ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum4
17秋 软件工程 团队第五次作业 Alpha Scrum4 今日完成的任务 世强:部门基础信息模块数据更新.部门审核提交: 港晨:设计编写登录界面的一部分: 树民:学习python基本语法.flask ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum5
17秋 软件工程 团队第五次作业 Alpha Scrum5 今日完成的任务 世强:消息通知管理列表页界面编写,下拉加载效果: 港晨:编写登录界面: 树民: 伟航:学习了flask_restful框架的 ...
- 17秋 软件工程 团队第五次作业 Alpha Scrum10
17秋 软件工程 团队第五次作业 Alpha Scrum10 今日完成的任务 世强:Android客户端成员列表完善.APP前端子部门和活动中心界面与数据交互: 港晨:Web前端主页的接口对接: 树民 ...
- 耿丹CS16-2班第五次作业汇总
Deadline: 2016-10-26 23:59 作业内容 实验4-1 求1到20的阶乘的和,其中求阶乘用函数完成. 实验4-2 写一个判素数的函数,在主函数输入一个整数,输出其是否是素数的信息. ...
- C 语言学习 第五次作业总结
第五次作业,主要学习和复习的是几种循环结构的使用. 在前一次的课堂上,同学们已经学习了分支语句的使用.分支语句和循环语句配合使用,就可以写出更多的,逻辑功能丰富的代码了. 逻辑功能的丰富,也意味着学习 ...
- C语言第五次作业——循环结构
C语言程序设计第五次作业--循环结构(1) (一)改错题 输出华氏摄氏温度转换表:输入两个整数lower和upper,输出一张华氏摄氏温度转换表,华氏温度的取值范围是{lower,upper},每次增 ...
随机推荐
- <一>类,对象,this指针
C++ 类:实体的抽象类型 实体(属性,行为) ->ADT(abstract data type) 类(属性->成员变量,行为->成员方法) OOP语言4大特征 抽象 封装/隐藏(通 ...
- 开发用户K8S授权
#开发用户没有K8S权限 [ans@master ~]$ kubectl get po Unable to connect to the server: x509: certificate signe ...
- nm命令解释
nm命令参数解释 -A 或-o或 --print-file-name:打印出每个符号属于的文件-a或--debug-syms:打印出所有符号,包括debug符号-B:BSD码显示-C或--demang ...
- SpringCloud(十一)- 秒杀 抢购
1.流程图 1.1 数据预热 1.2 抢购 1.3 生成订单 (发送订单消息) 1.4 订单入库 (监听 消费订单消息) 1.5 查看订单状态 1.6 支付 (获取支付链接 ) 1.7 支付成功 微信 ...
- ORCL 时间
一.计算时间差 两个Date类型字段:START_DATE,END_DATE,计算这两个日期的时间差(分别以天,小时,分钟,秒,毫秒): 天: ROUND(TO_NUMBER(END_DATE - S ...
- B-神经网络模型复杂度分析
前言 一,模型计算量分析 卷积层 FLOPs 计算 全连接层的 FLOPs 计算 二,模型参数量分析 卷积层参数量 BN 层参数量 全连接层参数量 三,模型内存访问代价计算 卷积层 MAC 计算 四, ...
- 漫谈计算机网络: 运输层 ------ 从UDP ->TCP , 从面向通信->面向用户,三次握手/四次挥手?
面试答不上?计网很枯燥? 听说你学习 计网 每次记了都会忘? 不妨抽时间和我一起多学学它 深入浅出,用你的空闲时间来探索计算机网络的硬核知识! 博主的上篇连载文章<初识图像处理技术> 图像 ...
- python字符串常用方法介绍,基于python3.10
python字符串常用方法-目录: 1.strip().lstrip().rstrip()2.removeprefix().removesuffix()3.replace()4.split().rsp ...
- 锂电池升压芯片,IC电路图资料
锂电池常规的供电电压范围是3V-4.2V之间,标称电压是3.7V.锂电池具有宽供电电压范围,需要进行降压或者升压到固定电压值,进行恒压输出,同时根据输出功率的不同,(输出功率=输出电压乘以输出电流). ...
- AIBOX视频边缘计算终端,助力识别人员违规行为!
目前,制造业工厂工作区布局分散,生产安全质量控制难度较大.人员擅自离岗.玩手机.区域入侵.吸烟.未穿反光衣.异物占位等违法行为不能及时控制,安全风险十分巨大.如果手动检查或通过人眼检查监控录像,不仅产 ...