Why is it recommended (different sources) not to overload the constructor for Fragment
s but use static Fragment.newInstance()
with passing a Bundle
to it?
When you overload a constructor you just explicitly define default one. Than, if your Fragment
would be recreated for some reason you use onSaveInstanceState()
with subsequent data extracting on onCreate()
. The similar situation with using Fragment.newInstance()
, the only difference you don't need to create public default constructor.
Am I understanding something wrong? Thank you very much.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…