Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mohanad0/12a28294ce22f0e68b2e491bbb2e6daa to your computer and use it in GitHub Desktop.
Save Mohanad0/12a28294ce22f0e68b2e491bbb2e6daa to your computer and use it in GitHub Desktop.
Use OnClickListeners for All Categories - onCreate method in MainActivity.java
// Find the View that shows the numbers category
TextView numbers = (TextView) findViewById(R.id.numbers);
// Set a click listener on that View
numbers.setOnClickListener(new View.OnClickListener() {
// The code in this method will be executed when the numbers View is clicked on.
@Override
public void onClick(View view) {
Intent numbersIntent = new Intent(MainActivity.this, NumbersActivity.class);
startActivity(numbersIntent);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment