the application does not run when i add onclick.listener

+1 ameni mighri · January 26, 2015
Hi , 
I just have started my first  android tutorials  with thenewboston.I waw following this one 
when i ru it the application stops n but when i delete the listener code , it runs on the divice 

 // add.setOnClickListener(new View.OnClickListener() {

//: @Override
/* public void onClick(View v) {
// TODO Auto-generated method stub
//counter++;
//mytext.setText("your score is " + counter);

}
});

      /* sub.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//counter--;
//mytext.setText("your score is " + counter);
}
});*/


I could not figure out what's the problem.

Post a Reply

Replies

Oldest  Newest  Rating
+1 Neil Cannon · January 26, 2015
Check check check all your code, you have made a typing error!
+1 M Uxi · January 27, 2015
You Can Follow Like this too its easy If you Want..
Just Write in XML "Onclick" Method in your Button With name Of "Increment"

public void Increment(View button1) 
{

TextView Tx = (TextView) findViewById(R.id.textView1);
Tx.setText(count+"");
count++;
}

Make Another Method For Decrement Too.
0 Troy Jones · January 26, 2015
Did you id your buttons in the onCreate method?

Button button = (Button) findViewById(R.id.bButton);
  • 1

Java / Android Development

107,230 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator