I have a couple of buttons that need to track the click. Each switches the screen to a new class. I want to make using the method, passing it a reference to the class to which the button switches. The problem is that an instance of the class is created in the method call, and I need to create it after releasing the button.

  • 2
    People, horses got mixed up in a bunch ... Need to pass a link to a class or still generate a button release event? The question is what? - Tachkin
  • try to make the method static - kuturu
  • Sorry, but what does it give? - 0xdb

1 answer 1

Well, what is actually the problem then? Pass type Class

 public void callListener(Class clz) { //blah-blah //через Java reflection создаем экземпляр класса clz и все такое } 

Call this: callListener(MyListener.class)