i have static method accepts couple of parameters. inside method creating new object , attaching new listener it. problem listener block needs access outer static method variables, don't know how reference them. know how make happen non static method, not static one.
here code:
v.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_up: ((activity)*context*).startactivityforresult(*intent*, 0); break; } return true; } });
the context , intent variables surrounded asterisks objects passed static method. since ontouchlistener inner block, unaware of objects. how can reference them?
declare parameters static method final or assign passed in arguments final local variables in static method before create listener. can use final references inside anonymous class definition.
Comments
Post a Comment