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. 夺命雷公狗—angularjs—15—内置封装好的计时器$interval和$timeout

    这里其实和js源生的效果是一样的,但是源生的在angularjs里面不能直接正常执行代码如下所示: <!DOCTYPE html> <html lang="en" ...

  2. DMA-330(二)

    DMA内部的block diagram: DMAC包含一个instruction processing block,来process program code,control DMA transfer ...

  3. 几款python集成开发环境

    以下软件的测试环境为ArchLinux64位系统.对软件的介绍很粗略,详细介绍参考官网. 1-名称:eric 官网:http://eric-ide.python-projects.org/ 特点:该软 ...

  4. linux 压缩文件的命令总结

    Linux压缩文件的读取 *.Z       compress 程序压缩的档案: *.bz2     bzip2 程序压缩的档案: *.gz      gzip 程序压缩的档案: *.tar     ...

  5. 新发现了一个编辑器HBuilder,感觉蛮好的,关键是国产软件。

    http://www.dcloud.io/

  6. Objective-C语言的面向对象特性

    Objective-C作为一种面向对象的编程语言,具有面向对象的基本特征,即:封装.继承和多态.主要介绍Objective-C中有关面向对象基本概念:类.对象.方法和属性等. 类是Objective- ...

  7. android 学习随笔十三(网络:多线程下载)

    多线程断点续传下载1.多线程:快* 原理:抢占服务器资源* 单线程下载:线程从第0个字节开始下,下到最后一个字节,在本地硬盘的临时文件中从第0个字节开始写,写到最后一个字节,下载完成时,临时文件也写完 ...

  8. 为 Macbook 安装 enca 命令

    enca 是个查看.转换编码的开源软件, 地址: http://dl.cihar.com/enca/ 安装的步骤比安装 wget 简单多了: 1.用 wget 获取最新的enca 的 tar.gz 的 ...

  9. andoid下的股票行情开发

    1.信息类 public class SinaStockInfo { /** * Sina股票数据接口 以大秦铁路(股票代码:601006)为例,如果要获取它的最新行情,只需访问新浪的股票数据 * 接 ...

  10. Oracle 行迁移和行链接

    一.行迁移 1.1.行迁移概念 当一个行上的更新操作(原来的数据存在且没有减少)导致当前的数据不能在容纳在当前块,我们需要进行行迁移.一个行迁移意味着整行数据将会移动,仅仅保留的是一个转移地址.因此整 ...