二、Button的id具有唯一性,应有唯一的标识。
1.使用Button应先在Java中定义,例:TextView tvResult;
Button Add,Sub;2.仅仅这样写Android还不能识别,继续在
protected void onCreate(Bundle savedInstanceState){ ... ... }中添加
tvResult=(TextView)findViewById(R.id.tvDisplay);(tvDisplay是TextView id的内容)Add=(Button)findViewById(R.id.btnAdd);(btnAdd是Button Add id的内容)
Sub=(Button)findViewById(R.id.btnSub);(btnSub是Button Sub id的内容)