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},每次增 ...
随机推荐
- 解决 net core 3.x 跨域问题
跨域:指的是浏览器不能执行其他网站的脚本.它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制. 以下几种情况是造成跨域的原因: 域名相同,端口不同 域名相同,协议不同(即,一个 ...
- Oracle生成awr报告操作步骤介绍
AWR全称Automatic Workload Repository,自动负载信息库,是Oracle 10g版本后推出的一种性能收集和分析工具,提供了一个时间段内整个系统的报表数据.通过AWR报告,可 ...
- 7 款殿堂级的开源 CMS(内容管理系统)
最近,有读者留言让我推荐开源 CMS.我本想直接回复 WordPress,但是转念一想我玩 WordPress 是 2010 年左右的事情了,都过去十年了,它会不会有些过时呢?有没有新的.更好玩的开源 ...
- 2022-11-14 Acwing每日一题
本系列所有题目均为Acwing课的内容,发表博客既是为了学习总结,加深自己的印象,同时也是为了以后回过头来看时,不会感叹虚度光阴罢了,因此如果出现错误,欢迎大家能够指出错误,我会认真改正的.同时也希望 ...
- golang 简书
https://www.jianshu.com/p/548adff0d10d Go 入门指南 https://github.com/wuxiaoxiaoshen/go-example-for-live ...
- RabbitMQ 常见问题
RabbitMQ 常见问题 昔我往矣,杨柳依依.今我来思,雨雪霏霏. 1.什么是RabbitMQ? RabbitMQ是一款开源的.Erlang编写的消息中间件:最大的特点就是消费并不需要确保提供方存 ...
- Kubernetes_手把手打镜像并运行到k8s容器上(亲测可用)
一.前言 本文使用两个机器 192.168.100.150 是master节点,192.168.100.151 是node1 节点,如下: 演示三个示例,第一个示例wordpress博客系统是指将别人 ...
- A-深度学习面试题
目录 目录 一,滤波器与卷积核 二,卷积层和池化输出大小计算 2.1,CNN 中术语解释 2.2,卷积输出大小计算(简化型) 2.3,理解边界效应与填充 padding 参考资料 三,深度学习框架的张 ...
- Spring Security(3)
您好,我是湘王,这是我的博客园,欢迎您来,欢迎您再来- 前面运行写好的代码之所以没有任何显示,是因为还没有对Spring Security进行配置,当然啥也不显示了.这就好比你坐在车上,却不打开发动机 ...
- 【Android】Configuration中的locale已过时
Configuration中有很多属性的设置,在编译时提示错误说locale已过时这个是设置语言的 使用最新的方法如下 configuration.setLocale(locale);