没有合适的资源?快使用搜索试试~ 我知道了~
android移动开发课程中计算器java文件
需积分: 14 2 下载量 152 浏览量
2019-05-14
21:53:20
上传
评论
收藏 7KB TXT 举报
温馨提示
试读
8页
android计算器主要代码,android移动开发课程中计算器java文件
资源推荐
资源详情
资源评论
package com.example.jisuanqi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
//创建Button对象 也就是activity_main.xml里所设置的ID
Button btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9, btn_pt;
Button btn_mul, btn_div, btn_add, btn_sub;
Button btn_clr, btn_del, btn_eq;
EditText et_input;
boolean clr_flag; //判断et编辑文本框中是否清空
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//实例化对象
setContentView(R.layout.activity_main);
btn_0 = (Button) findViewById(R.id.btn_0);
btn_1 = (Button) findViewById(R.id.btn_1);
btn_2 = (Button) findViewById(R.id.btn_2);
btn_3 = (Button) findViewById(R.id.btn_3);
btn_4 = (Button) findViewById(R.id.btn_4);
btn_5 = (Button) findViewById(R.id.btn_5);
btn_6 = (Button) findViewById(R.id.btn_6);
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
//创建Button对象 也就是activity_main.xml里所设置的ID
Button btn_0, btn_1, btn_2, btn_3, btn_4, btn_5, btn_6, btn_7, btn_8, btn_9, btn_pt;
Button btn_mul, btn_div, btn_add, btn_sub;
Button btn_clr, btn_del, btn_eq;
EditText et_input;
boolean clr_flag; //判断et编辑文本框中是否清空
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//实例化对象
setContentView(R.layout.activity_main);
btn_0 = (Button) findViewById(R.id.btn_0);
btn_1 = (Button) findViewById(R.id.btn_1);
btn_2 = (Button) findViewById(R.id.btn_2);
btn_3 = (Button) findViewById(R.id.btn_3);
btn_4 = (Button) findViewById(R.id.btn_4);
btn_5 = (Button) findViewById(R.id.btn_5);
btn_6 = (Button) findViewById(R.id.btn_6);
btn_7 = (Button) findViewById(R.id.btn_7);
btn_8 = (Button) findViewById(R.id.btn_8);
btn_9 = (Button) findViewById(R.id.btn_9);
btn_pt = (Button) findViewById(R.id.btn_pt);
btn_add = (Button) findViewById(R.id.btn_add);
btn_sub = (Button) findViewById(R.id.btn_sub);
btn_mul = (Button) findViewById(R.id.btn_mul);
btn_div = (Button) findViewById(R.id.btn_div);
btn_clr = (Button) findViewById(R.id.btn_clr);
btn_del = (Button) findViewById(R.id.btn_del);
btn_eq = (Button) findViewById(R.id.btn_eq);
et_input = (EditText) findViewById(R.id.et_input);
//给按钮设置的点击事件
btn_0.setOnClickListener(this);
btn_1.setOnClickListener(this);
btn_2.setOnClickListener(this);
btn_3.setOnClickListener(this);
btn_4.setOnClickListener(this);
btn_5.setOnClickListener(this);
btn_6.setOnClickListener(this);
btn_7.setOnClickListener(this);
btn_8.setOnClickListener(this);
btn_9.setOnClickListener(this);
btn_pt.setOnClickListener(this);
btn_add.setOnClickListener(this);
btn_sub.setOnClickListener(this);
btn_mul.setOnClickListener(this);
btn_div.setOnClickListener(this);
btn_clr.setOnClickListener(this);
btn_8 = (Button) findViewById(R.id.btn_8);
btn_9 = (Button) findViewById(R.id.btn_9);
btn_pt = (Button) findViewById(R.id.btn_pt);
btn_add = (Button) findViewById(R.id.btn_add);
btn_sub = (Button) findViewById(R.id.btn_sub);
btn_mul = (Button) findViewById(R.id.btn_mul);
btn_div = (Button) findViewById(R.id.btn_div);
btn_clr = (Button) findViewById(R.id.btn_clr);
btn_del = (Button) findViewById(R.id.btn_del);
btn_eq = (Button) findViewById(R.id.btn_eq);
et_input = (EditText) findViewById(R.id.et_input);
//给按钮设置的点击事件
btn_0.setOnClickListener(this);
btn_1.setOnClickListener(this);
btn_2.setOnClickListener(this);
btn_3.setOnClickListener(this);
btn_4.setOnClickListener(this);
btn_5.setOnClickListener(this);
btn_6.setOnClickListener(this);
btn_7.setOnClickListener(this);
btn_8.setOnClickListener(this);
btn_9.setOnClickListener(this);
btn_pt.setOnClickListener(this);
btn_add.setOnClickListener(this);
btn_sub.setOnClickListener(this);
btn_mul.setOnClickListener(this);
btn_div.setOnClickListener(this);
btn_clr.setOnClickListener(this);
剩余7页未读,继续阅读
资源评论
qq_45060476
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功