public class MainActivity extends ActionBarActivity { private Button but1 = null; private Button but2 = null; private Button but3 = null; private Button but4 = null; private EditText edt1 = null; private EditText edt2 = null; private TextView tv = null; int num1=0; int num2=0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_main); this.edt1 = (EditText) super.findViewById(R.id.edt1); this.edt2 = (EditText) super.findViewById(R.id.edt2); this.tv = (TextView) super.findViewById(R.id.result); this.but1.setOnClickListener(new OnClickListenerImpI()); this.but2.setOnClickListener(new OnClickListenerImpI2()); this.but3.setOnClickListener(new OnClickListenerImpI3()); this.but4.setOnClickListener(new OnClickListenerImpI4()); } private class OnClickListenerImpI implements OnClickListener { @Override public void onClick(View arg0) { // TODO Auto-generated method stub num1=Integer.parseInt(edt1.getText().toString()); num2=Integer.parseInt(edt2.getText().toString()); int result = num1 + num2; tv.setText(result); } }}
- 3 回答
- 0 关注
- 1400 浏览
添加回答
举报
0/150
提交
取消