My Fragment doesn't call onAttach(context)
method when it launched from AppCompatActivity
.
Fragment creating in XML:
<fragment
android:id="@+id/toolbar"
class="package.MainToolbarFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:layout="@layout/fragment_main_toolbar" />
But if I extends it from support.v4.Fragment
, onAttach(context)
call !
What could be the problem?
Of course, I can extend all fragments from v4.Fragment
, but I don't want it. Is it bad practice?
Also project min sdk 14.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…