admin 管理员组文章数量: 1184232
2023年12月25日发(作者:嵌入式软件开发待遇)
package ;
import ty;
import ;
import ;
import kListener;
import ;
import xt;
public class CalculatordemoActivity extends Activity implements OnClickListener {
private Button but0 = null;
private Button but1 = null;
private Button but2 = null;
private Button but3 = null;
private Button but4 = null;
private Button but5 = null;
private Button but6 = null;
private Button but7 = null;
private Button but8 = null;
private Button but9 = null;
private Button dim = null;
private Button add = null;
private Button sub = null;
private Button mult = null;
private Button div = null;
private Button equ = null;
private EditText etext = null;
private double value = 0;
/** Called when the activity is first created. */
private String str1 = null;
private String tem = "";
private String sign = "a";
@Override
public void onCreate(Bundle savedInstanceState) {
te(savedInstanceState);
tentView();
add = (Button) findViewById();
sub = (Button) findViewById();
mult = (Button) findViewById();
div = (Button) findViewById();
equ = (Button) findViewById(te);
but1 = (Button) findViewById(1);
but3 = (Button) findViewById(3);
but2 = (Button) findViewById(2);
but4 = (Button) findViewById(4);
but5 = (Button) findViewById(5);
but6 = (Button) findViewById(6);
but7 = (Button) findViewById(7);
but8 = (Button) findViewById(8);
but9 = (Button) findViewById(9);
but0 = (Button) findViewById(0);
dim = (Button) findViewById();
etext = (EditText) findViewById();
lickListener(new AListener());
lickListener(new AListener());
lickListener(new AListener());
lickListener(new AListener());
lickListener(new Listener());
}
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
lickListener(this);
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if ((but1)) {
}
if ((but2)) {
}
if ((but3)) {
tem = tem + "3";
t(tem);
tem = tem + "2";
t(tem);
tem = tem + "1";
t(tem);
}
if ((but4)) {
}
if ((but5)) {
}
if ((but6)) {
}
if ((but7)) {
}
if ((but8)) {
}
if ((but9)) {
}
if ((but0)) {
}
tem = tem + "0";
t(tem);
tem = tem + "9";
t(tem);
tem = tem + "8";
t(tem);
tem = tem + "7";
t(tem);
tem = tem + "6";
t(tem);
tem = tem + "5";
t(tem);
tem = tem + "4";
t(tem);
}
class AListener implements OnClickListener {
@Override
public void onClick(View arg) {
// TODO Auto-generated method stub
str1 = t().toString();
if (("")) {
} else {
double d = ouble(str1);
if (sign == "a") {
value = d;
}
if (sign == "*") {
value = value * d;
}
if (sign == "-") {
value = value - d;
}
if (sign == "/") {
value = value / d;
}
if (sign == "+") {
}
value = d + value;
}
}
t("");
if ((add)) {
}
if ((div)) {
}
if ((mult)) {
}
if ((sub)) {
}
tem = "";
sign = "-";
sign = "*";
sign = "/";
sign = "+";
}
class Listener implements OnClickListener {
@Override
public void onClick(View arg) {
// TODO Auto-generated method stub
str1 = t().toString();
if (("")) {
} else {
double d = ouble(str1);
if (sign == "a") {
}
value = d;
}
if (sign == "*") {
value = value * d;
}
if (sign == "-") {
value = value - d;
}
if (sign == "/") {
value = value / d;
}
if (sign == "+") {
value = d + value;
}
}
}
}
t(value + " ");
sign = "a";
value = 0;
tem = "";
android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > android:id="@+id/etext" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="5px" >
版权声明:本文标题:android简单计算器代码 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1703471907a452834.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论