Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public void displayActivity(View view) {
  2.  
  3. switch(view.getId()) {
  4. case R.id.secondActitityButton:
  5. myClass = SecondActivity.class;
  6. break;
  7. default:
  8. throw new RuntimeException("Unknown Button");
  9. }
  10.  
  11. Intent myIntent = new Intent (this, myClass);
  12. startActivity (myIntent);
  13. }
  14.  
  15. public void displayActivity(View view) {
  16. Class myClass;
  17. String className = (view.getContentDescription().toString().trim());
  18. try {
  19. myClass = Class.forName(className);
  20. }
  21. catch (ClassNotFoundException e) {
  22. myClass = MainActivity.class;
  23. }
  24.  
  25. Intent myIntent = new Intent (this, myClass);
  26. startActivity (myIntent);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement