package ymq.demo03;
import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.widget.*;
public class demo03 extends Activity {
/** Called when the activity is first created. */
String str="";
EditText et;
int c=0,flag=0;
double b=0.0,g=0.0,f=0.0;
View vi;
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
menu.add(0, 1, 1, "退出");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
if(item.getItemId()==1){finish();}
return super.onOptionsItemSelected(item);
}
//计算方法
public double calculater(){
switch(c){
case 0:f=g;break;
case 1:f=b+g;break;
case 2:f=b-g;break;
case 3:f=b*g;break;
case 4:f=b/g;break;
}
b=f;
c=0;
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//获得按键
final Button number[]=new Button[10];
final Button fuhao[]=new Button[11];
fuhao[0]=(Button)findViewById(R.id.button01);
fuhao[1]=(Button)findViewById(R.id.button02);
fuhao[2]=(Button)findViewById(R.id.button03);
fuhao[3]=(Button)findViewById(R.id.button04);
fuhao[4]=(Button)findViewById(R.id.button05);
fuhao[5]=(Button)findViewById(R.id.button06);
fuhao[6]=(Button)findViewById(R.id.buttonce);
fuhao[7]=(Button)findViewById(R.id.buttonc);
fuhao[8]=(Button)findViewById(R.id.zheng);
fuhao[9]=(Button)findViewById(R.id.kaifang);
fuhao[10]=(Button)findViewById(R.id.pingfang);
number[0]=(Button)findViewById(R.id.button0);
number[1]=(Button)findViewById(R.id.button1);
number[2]=(Button)findViewById(R.id.button2);
number[3]=(Button)findViewById(R.id.button3);
number[4]=(Button)findViewById(R.id.button4);
number[5]=(Button)findViewById(R.id.button5);
number[6]=(Button)findViewById(R.id.button6);
number[7]=(Butto
1