i have activity instantiate class interface. how can android context within myclass reference interface?
public class testactivity extends activity implements myinterface { @override public void oncreate(final bundle savedinstancestate) { final myclass myclass = new myclass(this); } @override public void onchange() { } } public interface myinterface { void onchange(); } public class myclass { public myclass(myinterface myinterface) { // how context myinterface ??? } }
public class myclass { public myclass(myinterface myinterface) { // context context context = null; if (myinterface instanceof context) context = (context)myinterface; } }
if activity
(which extends context
) implementing myinterface
, pass myclass
, need cast appropriate type.
Comments
Post a Comment