Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void displayActivity(View view) {
- switch(view.getId()) {
- case R.id.secondActitityButton:
- myClass = SecondActivity.class;
- break;
- default:
- throw new RuntimeException("Unknown Button");
- }
- Intent myIntent = new Intent (this, myClass);
- startActivity (myIntent);
- }
- public void displayActivity(View view) {
- Class myClass;
- String className = (view.getContentDescription().toString().trim());
- try {
- myClass = Class.forName(className);
- }
- catch (ClassNotFoundException e) {
- myClass = MainActivity.class;
- }
- Intent myIntent = new Intent (this, myClass);
- startActivity (myIntent);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement