(最新)计算器Android版(源码).pdf
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 bt_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 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_result=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);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_result);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_result=(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(););