android - Declare headless Fragment in layout XML? -
it possible declare headless fragment
in layout xml? perhaps attribute tells inflater not expect view
? when try this:
<fragment android:name="com.example.headlessfragment" android:id="@+id/headless_fragment" />
...not entirely unexpectedly, crashes this:
07-08 15:41:32.441: e/androidruntime(5943): caused by: java.lang.illegalstateexception: fragment com.example.headlessfragment did not create view.
no, can't
when declare fragment in tag, saying: "the following fragment added id parent view."
following statement, headless fragment added no parent view, not working. can have @ api add new fragment, need tag or container, , xml fragments make sense on second option.
beside that, code , file economy, if want have fragment in xml, makes more sense new whateverfragment()
layoutinflater.from(context).inflate(...);
Comments
Post a Comment