简单的摇筛子判断对比

布局代码

<?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:id="@+id/activity_main"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"android:orientation="vertical"tools:context="com.brose.a99brose.a001.MainActivity"android:weightSum="1"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:padding="25dp"android:gravity="center"><ImageViewandroid:id="@+id/ZT"android:layout_width="match_parent"android:layout_height="wrap_content"app:srcCompat="@drawable/oo"android:layout_weight="1" /><ImageViewandroid:id="@+id/YT"android:layout_width="match_parent"android:layout_height="wrap_content"app:srcCompat="@drawable/oo"android:layout_weight="1" /></LinearLayout><TextViewandroid:id="@+id/DXTXT"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="请选择大小"android:textSize="18dp"/><RadioGroupandroid:id="@+id/DX"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><RadioButtonandroid:id="@+id/D"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="大"android:checked="true" /><RadioButtonandroid:id="@+id/X"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="小"/></RadioGroup><TextViewandroid:id="@+id/JOTXT"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="请选择奇偶性"android:textSize="18dp"/><RadioGroupandroid:id="@+id/JO"android:layout_width="wrap_content"android:layout_height="wrap_content"android:orientation="horizontal"><RadioButtonandroid:id="@+id/JS"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"android:text="奇数"/><RadioButtonandroid:id="@+id/OS"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="偶数"/></RadioGroup><LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"><TextViewandroid:hint="当前选择的结果:"android:textSize="20dp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/JG"android:layout_weight="0.27"/><TextViewandroid:hint="奇数"android:textSize="20dp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/JG2"android:layout_weight="1" /><TextViewandroid:hint="大"android:textSize="20dp"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/JG1"android:layout_weight="1" /></LinearLayout><Buttonandroid:id="@+id/YYY"android:text="摇一摇"android:layout_width="match_parent"android:layout_height="wrap_content" /><LinearLayoutandroid:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"><TextViewandroid:text="摇一摇结果:"android:textSize="20dp"android:layout_width="146dp"android:layout_height="wrap_content"android:id="@+id/textView3" /><TextViewandroid:hint="我是结果"android:textSize="20dp"android:layout_width="157dp"android:layout_height="wrap_content"android:id="@+id/YYYJG" /></LinearLayout></LinearLayout>`

布局代码

程序代码

`package com.brose.a99brose.a001;import android.net.sip.SipAudioCall;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;public class MainActivity extends AppCompatActivity {private ImageView ZT,YT;private TextView JG1,JG2,YYYJG;private RadioGroup DX,JO;private RadioButton D,X,JS,OS;private Button YYY;private static int a,b,c,d;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//定义图片数组。final int[] images=new int[]{R.drawable.o1,R.drawable.o2,R.drawable.o3,R.drawable.o4,R.drawable.o5,R.drawable.o6};ZT=(ImageView)findViewById(R.id.ZT);//初始化左边图片YT=(ImageView)findViewById(R.id.YT);//初始化右边图片JG1=(TextView)findViewById(R.id.JG1);//初始化大小结果文本JG2=(TextView)findViewById(R.id.JG2);//初始化奇数、偶数结果文本YYYJG=(TextView)findViewById(R.id.YYYJG);//初始化摇一摇结果DX=(RadioGroup)findViewById(R.id.DX);//初始化选择大小的RadioGroupJO=(RadioGroup)findViewById(R.id.JO);//初始化选择奇偶性的RadioGroupD=(RadioButton)findViewById(R.id.D);//初始化大这个RadioButtonX=(RadioButton)findViewById(R.id.X);//初始化小这个RadioButtonJS=(RadioButton)findViewById(R.id.JS);//初始化奇数这个RadioButtonOS=(RadioButton)findViewById(R.id.OS);//初始化偶数这个RadioButtonYYY=(Button)findViewById(R.id.YYY); //初始化摇一摇这个按钮//设置RadioGroup监听事件DX.setOnCheckedChangeListener(dxChangeRadio);//实现选择大小点击的监听事件JO.setOnCheckedChangeListener(joChangeRadio);//实现选择奇偶点击的监听事件//设置摇一摇按钮监听事件YYY.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {int m=(int)(Math.random()*6);//6为  0,1,2,3,4,5一共6个。int n=(int)(Math.random()*6);ZT.setImageResource(images[m]);YT.setImageResource(images[n]);int z=m+n+2;if(z>6){if(z%2==0){YYYJG.setText("奇数     大");}else{YYYJG.setText("奇数     大");}}else{if(z%2==0){YYYJG.setText("偶数     小");}else{YYYJG.setText("奇数     小");}}}});}private RadioGroup.OnCheckedChangeListener dxChangeRadio = new RadioGroup.OnCheckedChangeListener() {@Overridepublic void onCheckedChanged(RadioGroup group, int checkedId) {// TODO Auto-generated method stubif (checkedId == D.getId()) {// 把大的内容传到结果JG1.setText(D.getText());} else if (checkedId == X.getId()) {// 把小的内容传到结果JG1.setText(X.getText());}}};private RadioGroup.OnCheckedChangeListener joChangeRadio=new RadioGroup.OnCheckedChangeListener(){public String WT;@Overridepublic void onCheckedChanged(RadioGroup group, int checkedId){if (checkedId == JS.getId()) {// 把奇数的内容传到结果文本WT=(String) JS.getText();} else if (checkedId == OS.getId()) {// 把偶数的内容传到结果文本WT=(String)OS.getText();}JG2.setText(WT);}};

简单的摇筛子判断对比相关推荐

  1. 一个简单的五子连珠小游戏

    一个简单的五子连珠小游戏 程序目的:设计一个五子连珠小游戏 1,棋盘大小是9X9 2,初始状态棋盘上随机分布着7个不同色的棋子. 3,当同色的棋子有5颗连在一起排成横向.纵向或者斜向时,游戏者可以得1 ...

  2. JavaScript如何简单而准确地判断复杂数据类型

    javaScript如何简单而准确地判断复杂数据类型? 1:typeof 只能判断出基本数据类型 例如: var a = 3; typeof a 的结果为 number var b = []; typ ...

  3. ICLR‘23 UnderReview | LightGCL: 简单而有效的图对比学习推荐系统

    上周末梳理了NeurlPS'22中推荐系统相关论文,详见NeurlPS'22 推荐系统论文梳理.本想精读其中某篇,但是并没有公开.最近知乎刷到很多ICLR'23的总结文章,我把他们汇总在ICLR'23 ...

  4. C语言if语句判断素数,利用简单的if语句判断素数

    8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 判断素数这个问题是c语言条件,循环中最简单的一个问题 下面就来介绍一下判断素数的代码吧 #include "s ...

  5. ios(iphone/ipad)一个简单的用代码判断当前设备的方法

    直接NSLog(@"current_device:%@",[UIDevice currentDevice].model); 即可看出它输出的是当前设备,所以根据这个字符串可简单的判 ...

  6. ACL 2021 | SimCLS: 概念简单但足够有效的对比学习摘要生成框架

    ©PaperWeekly 原创 · 作者 | Maple小七 学校 | 北京邮电大学硕士生 研究方向 | 自然语言处理 作者提出了一个概念简单但足够有效的摘要生成框架:SimCLS,在当前的 SOTA ...

  7. java double类型判空,简单封装JAVA空判断

    在项目开发过程中,面对各种各样的对象,如果稍不注意,就会发生NULL空指针报错;是不是很烦恼,特别是对重要的参数判读; 经过总结,把各种类型的空判断进行了简单的封装,对新手还是很方便的; packag ...

  8. 布隆过滤器简单实现添加和判断功能

    布隆过滤器 布隆过滤器是 1970 年由布隆提出的.它实际上是一个很长的二进制向量和一系列随机映射函数.主要用于判断一个元素是否在一个集合中. 通常我们会遇到很多要判断一个元素是否在某个集合中的业务场 ...

  9. 简单几步即可判断Linux系统有无被DDOS攻击的方法

    Dos攻击或者DDos攻击目的是使服务器或者网络资源耗尽,使其他用户无法使用.一般来说,这种攻击主要针对重要的网站或服务,比如银行.信用卡支付网关甚至是根域名服务器.Dos攻击主要通过强制目标主机重启 ...

最新文章

  1. 【机器学习】基于自适应变异粒子群算法的非线性函数寻优
  2. 身份证校验程序(上)- 零基础入门学习Delphi48
  3. 宝塔中mysql数据库命名小坑
  4. 第二十三期:程序员节Keep被曝突然裁员300多人,60%是开发和运营
  5. 国家计算机病毒中心发布违规 APP 和 SDK 名单
  6. 基于JAVA+SpringMVC+MYSQL的高校教师档案管理系统
  7. android 来电拒接_[系统漏洞]模拟耳机广播实现来电自动接听和拒接
  8. Nexmark: 如何设计一个流计算基准测试?
  9. html基础之select ,datalist与details的异同
  10. 通过PMP认证考试的心得分享
  11. TransE 论文笔记
  12. QQ音乐下载qmc0/3批量转MP3工具
  13. web打印POS小票机代码
  14. 路由汇总与路由聚合的区别
  15. Android APP漏洞自动化静态扫描检测工具-Qark
  16. 直播预告 | 猪齿鱼V1.1发布,线上新功能详解邀您参加
  17. java zero fill_一次JavaAssist引发的生产环境CPU报警的问题
  18. 七彩背景(Background)
  19. 《UEFI内核导读》全集,2023年更新
  20. [Windows] 系统安装利器WinNTSetup4.2 x86/x64 Final单文件版

热门文章

  1. 读博士可能后悔四年,不读博士可能后悔一辈子
  2. 云计算新十年 去中心化云计算发展之道
  3. 银行家算法 C语言实现
  4. jQuery的serializeArray()方法的使用---通过序列化表单值来创建对象(name 和 value)的数组
  5. 天了噜!豆瓣评分9.3,疯狂综艺榜榜首,《明星大侦探2》“开门红”
  6. ollyDBG 字体设置
  7. java动态分区分配_操作系统动态分区分配算法课程设计java版解析.doc
  8. PDF文件的书签怎么分级或降级
  9. 如何备份卡巴斯基的病毒库文件
  10. 【优化算法】蜂虎狩猎 (BEH) 算法【含Matlab源码 2278期】