安卓java计算器源代码_Java实现Andriod带看括弧的计算器代码

废话不多说了,一切尽在代码中,具体代码如下所示:

界面

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:background="#ff808080"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:cursorVisible="false"

android:gravity="right"

android:editable = "false"

android:text="0" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:layout_width="53sp"

android:layout_height="wrap_content"

android:text=" MEM :" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="0" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:layout_width="53sp"

android:layout_height="wrap_content"

android:text=" DEG" />

android:text="MC"

android:layout_width="106sp"

android:layout_height="wrap_content" />

android:text="C"

android:layout_width="fill_parent"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:text="DRG"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="sin"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="cos"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="tan"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="n!"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="Bksp"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:text="7"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="8"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="9"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="÷"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="("

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text=")"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:text="4"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="5"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="6"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="×"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="√"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="^"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:text="1"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="2"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="3"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="-"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="log"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="ln"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="57sp"

>

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:text="0"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="."

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="="

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="+"

android:layout_width="53sp"

android:layout_height="wrap_content" />

android:text="exit"

android:layout_width="106sp"

android:layout_height="wrap_content" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

>

android:layout_width="60sp"

android:layout_height="wrap_content"

android:text="reminder:" />

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="欢迎使用!-www.javaapk.com 提供源码" />

代码

package com.example.yanlei.mytk;

import android.os.Bundle;

import android.support.v7.app.AppCompatActivity;

import android.view.View;

import android.widget.AdapterView;

import android.widget.ArrayAdapter;

import android.widget.Button;

import android.widget.Spinner;

import java.util.ArrayList;

import java.util.List;

import android.app.Activity;

import android.content.Context;

import android.os.Bundle;

import android.view.View;

import android.view.ViewGroup;

import android.view.animation.AnimationUtils;

import android.widget.AdapterView;

import android.widget.BaseAdapter;

import android.widget.Gallery;

import android.widget.Gallery.LayoutParams;

import android.widget.ImageSwitcher;

import android.widget.ImageView;

import android.widget.ViewSwitcher;

import java.text.DecimalFormat;

import java.util.StringTokenizer;

import android.os.Bundle;

import android.R.integer;

import android.app.Activity;

import android.util.Log;

import android.view.Menu;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

// 定义变量

private Button[] btn = new Button[10];// 0~9十个数字

private EditText input;// 用于显示输出结果

private TextView mem, _drg, tip;

private Button div, mul, sub, add, equal, sin, cos, tan, log, ln, sqrt,

square, factorial, bksp, left, right, dot, exit, drg, mc, c;

public String str_old;

public String str_new;

public boolean vbegin = true;// 控制输入,true为重新输入,false为接着输入

public boolean drg_flag = true;// true为角度,false为弧度

public double pi = 4 * Math.atan(1);// π值

public boolean tip_lock = true;// true为正确,可以继续输入,false错误,输入锁定

public boolean equals_flag = true;// 是否在按下=之后输入,true为之前,false为之后

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

InitWigdet();

AllWigdetListener();

}

<
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值