1.MainActivity.java

 package com.example.administrator.testapp2;

 import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView; public class MainActivity extends AppCompatActivity { TextView tv_1; Button bt1;
Button bt2;
Button bt3;
Button bt4;
Button bt5;
Button bt6;
Button bt7;
Button bt8;
Button bt9;
Button bt0;
Button bt_add;
Button bt_jian;
Button bt_cheng;
Button bt_chu;
Button bt_kuohao;
Button bt_dian; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); tv_1 = (TextView)findViewById(R.id.tv_1); bt0 = (Button)findViewById(R.id.bt0);
bt0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("0");
}
});
bt1 = (Button)findViewById(R.id.bt1);
bt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("1");
}
});
bt2 = (Button)findViewById(R.id.bt2);
bt2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("2");
}
});
bt3 = (Button)findViewById(R.id.bt3);
bt3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("3");
}
});
bt4 = (Button)findViewById(R.id.bt4);
bt4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("4");
}
});
bt5 = (Button)findViewById(R.id.bt5);
bt5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("5");
}
});
bt6 = (Button)findViewById(R.id.bt6);
bt6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("6");
}
});
bt7 = (Button)findViewById(R.id.bt7);
bt7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("7");
}
});
bt8 = (Button)findViewById(R.id.bt8);
bt8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("8");
}
});
bt9 = (Button)findViewById(R.id.bt9);
bt9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("9");
}
});
bt_add = (Button)findViewById(R.id.bt_add);
bt_add.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("+");
}
});
bt_jian = (Button)findViewById(R.id.bt_jian);
bt_jian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("-");
}
});
bt_cheng = (Button)findViewById(R.id.bt_cheng);
bt_cheng.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("X");
}
});
bt_chu = (Button)findViewById(R.id.bt_chu);
bt_chu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("÷");
}
});
bt_dian = (Button)findViewById(R.id.bt_dian);
bt_dian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText(".");
}
});
bt_kuohao = (Button)findViewById(R.id.bt_kuohao);
bt_kuohao.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_1.setText("()");
}
});
}
}

2.jsq.xml

 <?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="5"
android:columnCount="4">
<TextView
android:layout_width="match_parent"
android:layout_height="220dp"
android:layout_columnSpan="4"
android:textSize="60dp"
android:gravity="right|bottom"
android:text="6"
android:textColor="#0F0"
android:paddingRight="10dp"
android:id="@+id/tv_1"/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CE"
android:layout_rowWeight="1"
android:id="@+id/bt_CE"
android:textSize="25sp"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="←"
android:id="@+id/bt_qc"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="÷"
android:id="@+id/bt_chu"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="X"
android:id="@+id/bt_cheng"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:id="@+id/bt7"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/bt8"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:id="@+id/bt9"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="@+id/bt_jian"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:id="@+id/bt4"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="@+id/bt5"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:id="@+id/bt6"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="@+id/bt_add"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:id="@+id/bt1"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:id="@+id/bt2"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:id="@+id/bt3"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:id="@+id/btdengyu"
android:textSize="25sp"
android:layout_columnWeight="1"
android:layout_rowSpan="2"
android:layout_rowWeight="1"
android:layout_gravity="fill"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/bt0"
android:textSize="25sp"
android:layout_columnWeight="1"
android:layout_rowWeight="1"/> <Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="."
android:id="@+id/bt_dian"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="()"
android:id="@+id/bt_kuohao"
android:textSize="25sp"
android:layout_rowWeight="1"
android:layout_columnWeight="1"/>
</GridLayout>

UI事件 计算器界面的更多相关文章

  1. UI事件监听的击穿

    什么是UI事件监听的击穿 在游戏视图中,有两个UI界面叠在一起的时候,单击一个空白处,却触发了被覆盖在下层了UI界面中的单击事件,这就是单击击穿了上层界面. 假设场景中放置了一个箱子,单击箱子会触发一 ...

  2. Android学习笔记--处理UI事件

    Handling UI Events 在Android里, 有不只一种方式可以截获用户与你的应用程序交互的事件. 在你的界面上处理事件时,你需要捕获用户与某个View实例交互时所产生的事件.View类 ...

  3. Java按钮控件数组实现计算器界面

    编写程序,通过按钮数组来管理界面中的所有按钮控件,从而使用最少的代码实现模拟的计算器界面. 思路如下: 创建一个类,通过extends使其继承窗体类JFrame: 创建一个JFrame对象,使用JFr ...

  4. [Xcode 实际操作]七、文件与数据-(23)UI Testing系统界面测试功能的使用

    目录:[Swift]Xcode实际操作 本文将演示UI Testing系统界面测试功能的使用. 如果项目中尚未引入界面测试功能,请点击项目属性面板->[General]面板左下角的[+]图标 - ...

  5. 免费素材:25套免费的 Web UI 设计的界面元素(转)

    Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...

  6. UI事件之load

    load事件属于CSS3规范中的UI事件,load事件处理程序在页面元素和资源(html/script/link/img等)全部加载完成后在window上触发,或在img元素加载完成后再img元素上触 ...

  7. Javascript高级编程学习笔记(61)—— 事件(5)UI事件

    UI事件 UI事件是指那些不一定与用户操作有关的事件 这些事件在DOM规范出现之前,都是以各种不同的形式存在于不同的浏览器 而在DOM事件中为了保证向后兼容,现有的UI事件如下: DOMActivat ...

  8. Xamarin XAML语言教程将XAML设计的UI显示到界面

    Xamarin XAML语言教程将XAML设计的UI显示到界面 如果通过XAML将UI设计好以后,就可以将XAML中的内容显示给用户了,也就是显示到界面上.由于创建XAML文件方式的不同,所以将XAM ...

  9. UI事件与内容,舞台与演员

    UI事件:创建/清除/显示/隐藏/填充内容/位置变化/形态变化/尺寸变化/颜色变化/ 非UI事件:点击/输入/拖动/

随机推荐

  1. struts2中的addActionError 、addFieldError、addActionMessage的方法

    一 addActionError ①概念addActionError是Action级别的错误消息 ②添加this.addActionError("错误信息"); ③显示<s: ...

  2. 我的代码观——关于ACM编程风格与librazy网友的对话

    序 在拙文 <高手看了,感觉惨不忍睹——关于“[ACM]杭电ACM题一直WA求高手看看代码”>中,我对ACMer们的一些代码“惯例”发表了我的看法, librazy网友在评论中给出了他的一 ...

  3. Swift数据类型简介

    用 Swift 编写 iOS 和 OS X 应用将是一场美妙的体验,Swift 之后也会不断开发新特性和兼容性. Swift 提供了与C.Objective-C的相似的基础数据类型,包含整数Int,浮 ...

  4. 试用版SQL Server 2008 R2 提示评估期已过

    解决SQL Server 2008提示评估期已过第一步:进入SQL2008配置工具中的安装中心第二步:再进入维护界面,选择版本升级第三步:进入产品密钥,输入密钥第四步:一直点下一步,直到升级完毕.SQ ...

  5. Centos的Inode及Block相关知识

    Centos的Inode及Block相关知识 时间:2016-06-04 01:54来源:blog.51cto.com 作者:"tao" 博客 举报 点击:173次 本经验均在Ce ...

  6. gerrit

    https://en.wikibooks.org/wiki/Git/Gerrit_Code_Review http://openwares.net/linux/gerrit2_setup.html 不 ...

  7. 解决tomcat占用8080端口问题图文教程

    在dos下,输入  netstat   -ano|findstr  8080 //说明:查看占用8080端口的进程 显示占用端口的进程 taskkill  /pid  6856  /f //说明,运行 ...

  8. 161109、windows下查看端口占用情况

    1.开始---->运行---->cmd,或者是window+R组合键,调出命令窗口 2.输入命令:netstat -ano,列出所有端口的情况.在列表中我们观察被占用的端口,比如是4915 ...

  9. n阶乘 尾数0的个数

    class Solution {public: int trailingZeroes(int n) {            if(n<=0) return 0; int i=0;        ...

  10. MySQL Replication的Reset slave重置命令

    有时要清除从库的所有复制信息,如切换为不同的Master, 主从重做等:Reset slave是一个比较危险的命令,所以在执行前一定要准备知道其含义. 1. 命令在slave上执行,执行前一定要停掉s ...