保存实例状态
对于 Integer、Long、String 等数据都可以,我只需将其放入包中,并在再次调用 onCreateView 时将其取回。但我的片段也有如下听众,
public class SomeFragment extends Fragment {
public interface SomeListener {
public void onStartDoingSomething(Object whatItIsDoing, Date when);
public void onDoneDoingTheThing(Object whatItDid, boolean result);
}
private SomeFragmentListener listener;
private String[] args;
public static SomeFragment getInstance(SomeListener _listener, String... _args) {
SomeFragment sf = new SomeFragment();
sf.listener = _listener
sf.args = _args
return sf;
}
// rest of the class
// the example of where do I invoke the listener are
// - onSetVisibilityHint
// - When AsyncTask is done
// - successfully download JSON
// etc.
}
我怎样才能让听众捆绑,以便我以后可以取回它?