当我在下面运行代码时,它会发出一条消息:
the application stopped unexcepctedlly pleas try again
任何人都可以帮助解决这个问题。
public class TheNewActivity extends Activity {
/** Called when the activity is first created. */
int counter;
Button sub,add;
TextView display;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
add=(Button) findViewById(R.id.button1);
display=(TextView) findViewById(R.id.dis);
add.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
counter++;
display.setText("your total is"+counter);
}
});
sub.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
counter--;
display.setText("your total is"+counter);
}
});
}
}