I have a class that implements an interface. From my base class, I'm creating an instance of the implemented class like this:
Class newTab;
TransactionTabInterface tabInterface = null;
try {
newTab = Class.forName("[package] + title);
tabInterface = (TransactionTabInterface) newTab.newInstance();
tabInterface.setRootController(this);
} catch (Exception e) {
e.printStackTrace();
}
This is necessary since I don't know the name of the class I need to instantiate (title
is determined elsewhere).
The problem I'm having is that, within the new class, I need access to rootController
immediately. I have a method within the class that allows me to pass the rootController
reference, as seen in my above code.
Normally, I would pass rootController
to the constructor when instantiating the class, but I don't know how to pass a parameter to the constructor in the newInstance()
call above.
Aucun commentaire:
Enregistrer un commentaire