《(最新)计算器Android版(源码).pdf》由会员分享,可在线阅读,更多相关《(最新)计算器Android版(源码).pdf(15页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、100%运行通过这是自己编写的,通过eclipse运行简易计算器Android 版(源码)这是自己整理得,欢迎大家下载说明:每完成一次计算后,需先clear 清除记忆,当然也可以连算XML布局源代码:package ;importclass Android_calculatorActivity extends Activityprivate Button bt_1;private Button bt_2;private Button bt_3;private Button bt_4;private Button bt_5;private Button bt_6;private Button b
2、t_7;private Button bt_8;private Button bt_9;private Button bt_0;private Button bt_add;private Button bt_sub;flag =false;);(new OnClickListener()Overridepublicvoid onClick(View v)if ()!=0)()-1);(););(new OnClickListener()Overridepublicvoid onClick(View v)str_oper=+;if (!()=)num1 +=();str_display=new
3、StringBuffer();if (!(str_result=null)num1 =(str_result);str_result=null;(num1);flag =true;);(new OnClickListener()Overridepublicvoid onClick(View v)str_oper=-;if (!b_sub&!()=)num1 =();(num1);str_display=new StringBuffer();b_sub =true;elseif (!()=)num1 -=();str_display=new StringBuffer();if (!(str_re
4、sult=null)num1 =(str_result);str_result=null;(num1);flag =true;);(new OnClickListener()Overridepublicvoid onClick(View v)str_oper=*;if (!b_mul&!()=)num1 =();(num1);str_display=new StringBuffer();b_mul =true;elseif (!()=)num1 *=();str_display=new StringBuffer();if (!(str_result=null)num1 =(str_result
5、);str_result=null;(num1);flag =true;);(new OnClickListener()Overridepublicvoid onClick(View v)str_oper=/;if (!b_div&!()=)num1 =();(num1);str_display=new StringBuffer();b_div =true;elseif (!()=)if ()=0),除数不能为0!,.show();elsenum1/=();str_display=new StringBuffer();if (!(str_result=null)num1 =(str_resul
6、t);str_result=null;(num1);flag =true;);(new OnClickListener()Overridepublicvoid onClick(View v)str_oper=+;str_display=new StringBuffer();str_result=null;num1=0;num2=0;flag =true;b_sub =false;b_mul =false;b_div =false;(););(new OnClickListener()Overridepublicvoid onClick(View v)if (+)num2 =();str_res
7、ult=(num1 +num2);(str_result);str_display=new StringBuffer();if (-)num2 =();str_result=(num1 -num2);(str_result);str_display=new StringBuffer();if (*)num2 =();str_result=(num1 *num2);(str_result);str_display=new StringBuffer();if (/)num2 =();if (!(num2 =0)str_result=(num1 /num2);(str_result);else,除数不能为 0!,.show();str_display=new StringBuffer(););