Android/Java Calling a function from an activity that instantiated the current class -
first time posting question self hope i'm doing right.
in android application, i've got activity called "sessiondetails.java". in class have called upon custom class ("customexpandableview.java") creates custom expandable list layout me. creating different instances of class "parentslice.java" , subsequently creating different instances of class "childslice.java" every 1 of parentslices. childslices have text info on it, have imageview on it.
so far i've got working fine, list expands , collapses supposed , imageviews displayed when list instantiated "sessiondetails.java" , not when instantiated "session.java", while icon shows on slices should have icon.
what want achieve, however, when button on childslice pressed, things in orginal activity of sessiondetails change.
what i've tried far pass along context of class instantiates (parse "this"), since can called either "sessiondetails" or "session" can not utilize this, because context variable determined @ run time.
i've tried set custom event handler "onplotrequestlistener" got stuck on not understand how fire custom event et cetera.
so bascially question this: how phone call function/method class instantiated current class? can via standard onclick method? if so, how!
simplistic example:
public class extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.layout_session_details_screen); b myb = new b(this); } public void dostufftoactivity() { } } public class b { public b(context context) { imageview icon = new imageview(context) icon.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { //here want phone call function of activity. //this not work. context.dostufftoactivity(); //making static method in wont work, because can't alter, example, textview on activity. //i've tried create own event handler, couldn't figure out. } }); } }
if tell me how should go this, happy.
on request post code, think create confusing.
thanks in advance.
java android
No comments:
Post a Comment