When I run below code, it’s giving a message that:
the application stopped unexcepctedlly pleas try again
Any one can help to deal with this problem.
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);
}
});
}
}
Here no sub button Reference like this add=(Button) findViewById(R.id.button1);
Thanks