I am practicing from the book Hello,Android ed3.There is an example code on creating an action button to display 'About' the game.I have edited all the necessary xml files.I am getting error in the following code.logcat is showing nullpointer exception in line 10: about.Button.setClickListener(this).Please help.Also i have been unable to understand 'this' parameter.Any hep?
public class Sudoku extends Activity implements OnClickListener {
private static final String TAG = "Sudoku";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Set up click listeners for all the button
View aboutButton = findViewById(R.id.about_button);
aboutButton.setOnClickListener(this);
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.about_button:
Intent i = new Intent(this, About.class);
startActivity(i);
break;
}
} }