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

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

SQL Server - MyCTE query based on 24 hour period (next day) -