android简单计算器代码.docx
- 文档编号:15935317
- 上传时间:2023-07-09
- 格式:DOCX
- 页数:11
- 大小:15.01KB
android简单计算器代码.docx
《android简单计算器代码.docx》由会员分享,可在线阅读,更多相关《android简单计算器代码.docx(11页珍藏版)》请在冰点文库上搜索。
android简单计算器代码
packageclassCalculatordemoActivityextendsActivityimplementsOnClickListener{
/**Calledwhentheactivityisfirstcreated.*/
privateButtonbut0=null;
privateButtonbut1=null;
privateButtonbut2=null;
privateButtonbut3=null;
privateButtonbut4=null;
privateButtonbut5=null;
privateButtonbut6=null;
…
privateButtonbut7=null;
privateButtonbut8=null;
privateButtonbut9=null;
privateButtondim=null;
privateButtonadd=null;
privateButtonsub=null;
privateButtonmult=null;
privateButtondiv=null;
privateButtonequ=null;
privateEditTextetext=null;
@
privatedoublevalue=0;
privateStringstr1=null;
privateStringtem="";
privateStringsign="a";
@Override
publicvoidonCreate(BundlesavedInstanceState){
(savedInstanceState);
add=(Button)findViewByIdsub=(Button)findViewByIdmult=(Button)findViewByIddiv=(Button)findViewByIdequ=(Button)findViewByIdbut1=(Button)findViewByIdbut3=(Button)findViewByIdbut2=(Button)findViewByIdbut4=(Button)findViewByIdbut5=(Button)findViewByIdbut6=(Button)findViewByIdbut7=(Button)findViewByIdbut8=(Button)findViewByIdbut9=(Button)findViewByIdbut0=(Button)findViewByIddim=(Button)findViewByIdetext=(EditText)findViewById(newAListener());
(newAListener());
<
(newAListener());
(newAListener());
(newListener());
(this);
(this);
(this);
(this);
(this);
(this);
"
(this);
(this);
(this);
(this);
(this);
}
@Override
publicvoidonClick(Viewv){
oString();
…
if("")){
}else{
doubled=(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;
}
}
("");
if(add)){
sign="+";
}
if(div)){
sign="/";
-
}
if(mult)){
sign="*";
}
if(sub)){
sign="-";
}
tem="";
}
】
}
classListenerimplementsOnClickListener{
@Override
publicvoidonClick(Viewarg){
oString();
if("")){
}else{
doubled=(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;
}
}
.
(value+"");
sign="a";
value=0;
tem="";
}
}
}
android="" ) 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"> —
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- android 简单 计算器 代码
![提示](https://static.bingdoc.com/images/bang_tan.gif)