android典型监听事件实

public class MainActivity extends Activity
{
int counter;
Button add, sub;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
counter = 0;
add = (Button) findViewById(R.id.bAddOne);
sub = (Button) findViewById(R.id.bSubOne);
display = (TextView) findViewById(R.id.tvDisplay);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
counter++;
display.setText("Your total is " + counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
counter--;
display.setText("Your total is " + counter);
}
});
}
}

上一篇:STL学习系列七:优先级队列priority_queue容器


下一篇:[典型漏洞分享]结合YS业务分析使用oauth协议的风险