Get & Set Value of my Activity from a fragment - Android -
Get & Set Value of my Activity from a fragment - Android -
i know how can , set value of activity fragment?? possible?
below activity , attribute 'mystation' value want , set fragment.
public class myactivity extends activity implements navigationdrawerfragment.navigationdrawercallbacks { public static station mystation;
in fragment can execute 'getactivity()' don't know if can that. if i'm wrong, right process?¿
thanks.
if fragment used in activity, can cast activity. otherwise you'll have verify right activity perhaps using instance of.
let's @ simpler case:
public class myactivity extends activity { private boolean myflag; public boolean getmyflag() { homecoming myflag; } public void setmyflag(boolean myflag) { this.myflag = myflag; }
and here fragment adjust flag.
public class myuniquefragment extends fragment { public void updateactivityflag(boolean myflag) { myactivity myactivity = (myactivity) getactivity(); myactivity.setmyflag(myflag); } }
android android-activity android-fragments
Comments
Post a Comment